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 models
+26
View File
@@ -0,0 +1,26 @@
{
'name': 'UBL Import - Apply Fiscal Position Tax Mapping',
'version': '16.0.1.0.0',
'summary': 'Applies supplier fiscal position tax mapping during UBL/EDI invoice import',
'description': """
Odoo 16 does not apply fiscal positions to vendor bills during UBL
import (_import_fill_invoice_line_taxes only searches by percentage,
ignoring fiscal position entirely).
This module overrides that method to apply the partner's fiscal
position tax mapping immediately after tax detection, so the correct
tax code is set without any manual correction.
Usage:
- Set a Fiscal Position on the supplier (Verkopen & Inkopen tab)
- Add the correct tax mapping in that Fiscal Position
- Import UBL invoices as usual - taxes will be corrected automatically
""",
'author': 'Busenco / Villajoyosa Digital',
'category': 'Accounting',
'depends': ['account_edi_ubl_cii'],
'data': [],
'installable': True,
'auto_install': False,
'license': 'LGPL-3',
}
+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