Skip to content

Commit 4379884

Browse files
[FIX] intrastat_product: no longer use is_valid from stdnum.vatin lib and use Odoo's validation
1 parent f172138 commit 4379884

5 files changed

Lines changed: 51 additions & 46 deletions

File tree

intrastat_product/README.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ reporting.
3434
It should be used in combination with country-specific Intrastat Product
3535
reporting modules such as:
3636

37-
- *l10n_fr_intrastat_product*: the module for the *Déclaration d'Echange
38-
de Biens* (DEB) for France
39-
- *l10n_be_intrastat_product*: the module for the Intrastat Product
40-
Declaration for Belgium
37+
- *l10n_fr_intrastat_product*: the module for the *Déclaration
38+
d'Echange de Biens* (DEB) for France
39+
- *l10n_be_intrastat_product*: the module for the Intrastat Product
40+
Declaration for Belgium
4141

4242
These country-specific modules can be found in the OCA localization for
4343
those countries.
@@ -90,40 +90,40 @@ We recommend to start by copying an existing module, e.g.
9090
l10n_be_intrastat_product and adapt the code for the specific needs of
9191
your country.
9292

93-
- Declaration Object
93+
- Declaration Object
9494

95-
Create a new class as follows:
95+
Create a new class as follows:
9696

97-
.. code:: python
97+
.. code:: python
9898
99-
class L10nCcIntrastatProductDeclaration(models.Model):
100-
_name = 'l10n.cc.intrastat.product.declaration'
101-
_description = "Intrastat Product Declaration for YourCountry"
102-
_inherit = ['intrastat.product.declaration', 'mail.thread']
99+
class L10nCcIntrastatProductDeclaration(models.Model):
100+
_name = 'l10n.cc.intrastat.product.declaration'
101+
_description = "Intrastat Product Declaration for YourCountry"
102+
_inherit = ['intrastat.product.declaration', 'mail.thread']
103103
104-
whereby cc = your country code
104+
whereby cc = your country code
105105

106-
- Computation & Declaration Lines
106+
- Computation & Declaration Lines
107107

108-
Create also new objects inheriting from the Computation and
109-
Declaration Line Objects so that you can add methods or customise the
110-
methods from the base modules (make a PR when the customization or new
111-
method is required for multiple countries).
108+
Create also new objects inheriting from the Computation and
109+
Declaration Line Objects so that you can add methods or customise the
110+
methods from the base modules (make a PR when the customization or
111+
new method is required for multiple countries).
112112

113-
Adapt also the parent_id fields of the newly created objects (cf.
114-
l10n_be_intrastat_product as example).
113+
Adapt also the parent_id fields of the newly created objects (cf.
114+
l10n_be_intrastat_product as example).
115115

116-
- XML Files: Menu, Action, Views
116+
- XML Files: Menu, Action, Views
117117

118-
Cf. l10n_be_istrastat_product as example, replace "be" by your Country
119-
Code.
118+
Cf. l10n_be_istrastat_product as example, replace "be" by your
119+
Country Code.
120120

121121
**Other functionality added by this module:**
122122

123-
- Compute the Intrastat Lines in an invoice. For this, your user needs
124-
to be in the "Technical / Invoice Intrastat Transaction Details"
125-
group. Go to the "Intrastat transaction details" tab and press
126-
**Compute**
123+
- Compute the Intrastat Lines in an invoice. For this, your user needs
124+
to be in the "Technical / Invoice Intrastat Transaction Details"
125+
group. Go to the "Intrastat transaction details" tab and press
126+
**Compute**
127127

128128
Known issues / Roadmap
129129
======================
@@ -158,16 +158,16 @@ Authors
158158
Contributors
159159
------------
160160

161-
- Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
161+
- Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
162162

163-
- Luc De Meyer, Noviat <info@noviat.com>
163+
- Luc De Meyer, Noviat <info@noviat.com>
164164

165-
- Denis Roussel <denis.roussel@acsone.eu>
165+
- Denis Roussel <denis.roussel@acsone.eu>
166166

167-
- Tecnativa <`www.tecnativa.com\\> <http://www.tecnativa.com\>>`__:
167+
- Tecnativa <`www.tecnativa.com <http://www.tecnativa.com>`__>:
168168

169-
- João Marques
170-
- Víctor Martínez
169+
- João Marques
170+
- Víctor Martínez
171171

172172
Maintainers
173173
-----------

intrastat_product/__manifest__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"report_xlsx_helper",
2323
],
2424
"excludes": ["account_intrastat"],
25-
"external_dependencies": {"python": ["python-stdnum>=1.16"]},
2625
"data": [
2726
"security/intrastat_security.xml",
2827
"security/ir.model.access.csv",

intrastat_product/models/intrastat_product_declaration.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from datetime import date
99

1010
from dateutil.relativedelta import relativedelta
11-
from stdnum.vatin import is_valid
1211

1312
from odoo import Command, _, api, fields, models
1413
from odoo.exceptions import RedirectWarning, UserError, ValidationError
@@ -1128,9 +1127,18 @@ def _compute_product_origin_country_code(self):
11281127

11291128
@api.constrains("vat")
11301129
def _check_vat(self):
1130+
partner_obj = self.env["res.partner"]
11311131
for this in self:
1132-
if this.vat and not is_valid(this.vat):
1133-
raise ValidationError(_("The VAT number '%s' is invalid.") % this.vat)
1132+
if not this.vat:
1133+
continue
1134+
country = this.partner_id.commercial_partner_id.country_id
1135+
if not partner_obj._run_vat_test(this.vat, country):
1136+
msg = partner_obj._build_vat_error_message(
1137+
country and country.code.lower() or None,
1138+
this.vat,
1139+
_("partner [%s]") % this.partner_id.name,
1140+
)
1141+
raise ValidationError(msg)
11341142

11351143
@api.depends("partner_id")
11361144
def _compute_vat(self):

intrastat_product/static/description/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ <h1 class="title">Intrastat Product</h1>
375375
<p>It should be used in combination with country-specific Intrastat Product
376376
reporting modules such as:</p>
377377
<ul class="simple">
378-
<li><em>l10n_fr_intrastat_product</em>: the module for the <em>Déclaration d’Echange
379-
de Biens</em> (DEB) for France</li>
378+
<li><em>l10n_fr_intrastat_product</em>: the module for the <em>Déclaration
379+
d’Echange de Biens</em> (DEB) for France</li>
380380
<li><em>l10n_be_intrastat_product</em>: the module for the Intrastat Product
381381
Declaration for Belgium</li>
382382
</ul>
@@ -436,7 +436,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
436436
<li><p class="first">Declaration Object</p>
437437
<p>Create a new class as follows:</p>
438438
<pre class="code python literal-block">
439-
<span class="k">class</span> <span class="nc">L10nCcIntrastatProductDeclaration</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span><span class="w">
439+
<span class="k">class</span><span class="w"> </span><span class="nc">L10nCcIntrastatProductDeclaration</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span><span class="w">
440440
</span> <span class="n">_name</span> <span class="o">=</span> <span class="s1">'l10n.cc.intrastat.product.declaration'</span><span class="w">
441441
</span> <span class="n">_description</span> <span class="o">=</span> <span class="s2">&quot;Intrastat Product Declaration for YourCountry&quot;</span><span class="w">
442442
</span> <span class="n">_inherit</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'intrastat.product.declaration'</span><span class="p">,</span> <span class="s1">'mail.thread'</span><span class="p">]</span>
@@ -446,14 +446,14 @@ <h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
446446
<li><p class="first">Computation &amp; Declaration Lines</p>
447447
<p>Create also new objects inheriting from the Computation and
448448
Declaration Line Objects so that you can add methods or customise the
449-
methods from the base modules (make a PR when the customization or new
450-
method is required for multiple countries).</p>
449+
methods from the base modules (make a PR when the customization or
450+
new method is required for multiple countries).</p>
451451
<p>Adapt also the parent_id fields of the newly created objects (cf.
452452
l10n_be_intrastat_product as example).</p>
453453
</li>
454454
<li><p class="first">XML Files: Menu, Action, Views</p>
455-
<p>Cf. l10n_be_istrastat_product as example, replace “be” by your Country
456-
Code.</p>
455+
<p>Cf. l10n_be_istrastat_product as example, replace “be” by your
456+
Country Code.</p>
457457
</li>
458458
</ul>
459459
<p><strong>Other functionality added by this module:</strong></p>
@@ -499,7 +499,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
499499
</li>
500500
<li><p class="first">Denis Roussel &lt;<a class="reference external" href="mailto:denis.roussel&#64;acsone.eu">denis.roussel&#64;acsone.eu</a>&gt;</p>
501501
</li>
502-
<li><p class="first">Tecnativa &lt;<a class="reference external" href="http://www.tecnativa.com&gt;">www.tecnativa.com\&gt;</a>:</p>
502+
<li><p class="first">Tecnativa &lt;<a class="reference external" href="http://www.tecnativa.com">www.tecnativa.com</a>&gt;:</p>
503503
<blockquote>
504504
<ul class="simple">
505505
<li>João Marques</li>

requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)