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