diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2020-10-02 14:30:20 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2020-10-06 11:29:25 +0000 |
| commit | 756000551be5508dce83820c7f014ded6894406f (patch) | |
| tree | d5e46717816cc63723fa20544dfbd4ce79d90bd3 /addons | |
| parent | 216e2e243c9747ecbcf98c7be5d810813c494167 (diff) | |
[FIX] base_vat: check VAT numbers UAxxx
- Go to the Contacts app
- Click on the Azure Interior company, or any other company with multiple associated people
- Set the country to Mexico
- Edit the VAT field and enter the following string: UAC070620MB3
Traceback will happen after hitting save.
It happens because `self` is a recordset in this case. Moreover, while
the VAT number starts with `UA`, the country is Mexico so the check is
incorrct.
opw-2348045
closes odoo/odoo#59257
X-original-commit: 3dbdc62b3458e9af2e74d8552a17d629dc7e2393
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/base_vat/models/res_partner.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py index 25b9ddb0835..00014929de8 100644 --- a/addons/base_vat/models/res_partner.py +++ b/addons/base_vat/models/res_partner.py @@ -448,13 +448,24 @@ class ResPartner(models.Model): return False def check_vat_ua(self, vat): - if self.is_company: - if len(vat) == 12: - return True - else: - if len(vat) == 10 or len(vat) == 9: - return True - return False + res = [] + for partner in self: + if partner.commercial_partner_id.country_id.code == 'MX': + if len(vat) == 10: + res.append(True) + else: + res.append(False) + elif partner.commercial_partner_id.is_company: + if len(vat) == 12: + res.append(True) + else: + res.append(False) + else: + if len(vat) == 10 or len(vat) == 9: + res.append(True) + else: + res.append(False) + return all(res) def check_vat_in(self, vat): #reference from https://www.gstzen.in/a/format-of-a-gst-number-gstin.html |
