Skip to content

Commit

Permalink
Merge PR #217 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by robinkeunen
  • Loading branch information
OCA-git-bot committed Apr 19, 2024
2 parents 685f297 + 9b69a90 commit 1902979
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion l10n_be_vat_reports/wizard/partner_vat_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def get_partners(self):
partners = partner_vat_list_client_model.browse([])
turnover_tags = ("00", "01", "02", "03", "45", "49")
vat_tags = ("54", "64")
be_id = self.env.ref("base.be").id

# query explanation:
#
Expand Down Expand Up @@ -156,7 +157,9 @@ def get_partners(self):
}
self.env.cr.execute(query, args)
for seq, record in enumerate(self.env.cr.dictfetchall(), start=1):
record["vat"] = record["vat"].replace(" ", "").upper()
record["vat"] = self.env["res.partner"].fix_eu_vat_number(
be_id, record["vat"]
)
record["seq"] = seq
partners |= partner_vat_list_client_model.create(record)

Expand Down
6 changes: 3 additions & 3 deletions l10n_be_vat_reports/wizard/partner_vat_list_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ class VATListingClients(models.TransientModel):
@api.constrains("vat")
def _check_vat_number(self):
"""
Belgium VAT numbers must respect this pattern: 0[1-9]{1}[0-9]{8}
Belgium VAT numbers must respect this pattern: [0-1][0-9]{9}
todo current code assumes vat numbers start with a two-letter
country code
"""
be_vat_pattern = re.compile(r"^BE0[1-9]{1}[0-9]{8}$")
be_vat_pattern = re.compile(r"^BE[0-1][0-9]{9}$")
for client in self:
if not be_vat_pattern.match(client.vat):
raise ValidationError(
_(
"Belgian Intervat platform only accepts VAT numbers "
"matching this pattern: 0[1-9]{1}[0-9]{8} (number "
"matching this pattern: [0-1][0-9]{9} (number "
"part). Check vat number %s for client %s"
)
% (client.vat, client.name)
Expand Down

0 comments on commit 1902979

Please sign in to comment.