Skip to content
Snippets Groups Projects
Commit 93073499 authored by John (jol)'s avatar John (jol) Committed by John Laterre (jol)
Browse files

[FIX] account: fix fiscal position with delivery address


The goal is to ensure that 2 conditions are met for a fiscal position to
be applied (within the EU):

- The customer must have a valid VAT number from another EU Member State
- The goods must leave the country of origin

closes odoo/odoo#81817

Task: 2596204
X-original-commit: ca0fc6cd
Signed-off-by: default avatarQuentin De Paoli <qdp@odoo.com>
Signed-off-by: default avatarJohn Laterre <jol@odoo.com>
parent 3c452f9f
No related branches found
No related tags found
No related merge requests found
......@@ -168,11 +168,17 @@ class AccountFiscalPosition(models.Model):
# This can be easily overridden to apply more complex fiscal rules
PartnerObj = self.env['res.partner']
partner = PartnerObj.browse(partner_id)
delivery = PartnerObj.browse(delivery_id)
# if no delivery use invoicing
if delivery_id:
delivery = PartnerObj.browse(delivery_id)
else:
company = self.env.company
eu_country_codes = set(self.env.ref('base.europe').country_ids.mapped('code'))
intra_eu = vat_exclusion = False
if company.vat and partner.vat:
intra_eu = company.vat[:2] in eu_country_codes and partner.vat[:2] in eu_country_codes
vat_exclusion = company.vat[:2] == partner.vat[:2]
# If company and partner have the same vat prefix (and are both within the EU), use invoicing
if not delivery or (intra_eu and vat_exclusion):
delivery = partner
# partner manually set fiscal position always win
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment