[FIX] base: disable same vat warning when using single-char vat

In order to ease the process of setting vats for some users, it was
decided to allow to use a vat number of a single character ('/' for
example) without checking it. This allows to differentiate between
partners for which we did not set VAT yet, and partners exempted from
VAT/without a number.

The VAT check was recently adapted to handle this use case, but the
"same vat" warning was forgotten in the process.

This additional change will disable the "same vat" warning that appears
when two partners share the same VAT number if that vat number is
only a single character, aligning the behavior of the warning to the
changes done in the vat check itself.

closes odoo/odoo#114640

X-original-commit: 4d80d30d0db6993a2fbbab59b935abe07080074b
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Nicolas Viseur (vin) <vin@odoo.com>
This commit is contained in:
Nicolas (vin)
2023-03-08 10:31:18 +01:00
parent bd2bf1a30f
commit 9461d2d52b
+3 -1
View File
@@ -374,7 +374,9 @@ class Partner(models.Model):
domain += [('company_id', 'in', [False, partner.company_id.id])]
if partner_id:
domain += [('id', '!=', partner_id), '!', ('id', 'child_of', partner_id)]
partner.same_vat_partner_id = bool(partner.vat) and not partner.parent_id and Partner.search(domain, limit=1)
# For VAT number being only one character, we will skip the check just like the regular check_vat
should_check_vat = partner.vat and len(partner.vat) != 1
partner.same_vat_partner_id = should_check_vat and not partner.parent_id and Partner.search(domain, limit=1)
# check company_registry
domain = [
('company_registry', '=', partner.company_registry),