new account_edi_ubl_fiscal_position

This commit is contained in:
Kristof Bernaert
2026-03-27 19:17:54 +01:00
parent 711e65c63c
commit 9f09c7a14f
4 changed files with 66 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
from . import account_edi_common
@@ -0,0 +1,38 @@
from odoo import models
class AccountEdiCommon(models.AbstractModel):
_inherit = 'account.edi.common'
def _import_fill_invoice_line_taxes(
self, journal, tax_nodes, invoice_line_form, inv_line_vals, logs
):
"""
Override to apply the supplier's fiscal position tax mapping after
the standard UBL tax detection.
Odoo 16 does not apply fiscal positions to vendor bills during UBL
import. The standard method only searches by percentage (amount=6,
limit=1), ignoring fiscal position entirely. This override applies
the partner's fiscal position mapping immediately after detection.
"""
# Run standard tax detection first
logs = super()._import_fill_invoice_line_taxes(
journal, tax_nodes, invoice_line_form, inv_line_vals, logs
)
# Apply fiscal position mapping if the invoice has one
move = invoice_line_form.move_id
fiscal_position = move.fiscal_position_id
if not fiscal_position or not inv_line_vals.get('taxes'):
return logs
detected_taxes = self.env['account.tax'].browse(inv_line_vals['taxes'])
mapped_taxes = fiscal_position.map_tax(detected_taxes)
if mapped_taxes != detected_taxes:
inv_line_vals['taxes'] = mapped_taxes.ids
invoice_line_form.tax_ids = mapped_taxes
return logs