From c1ef82225e8ed71e78194cfe1c1fd2d8bbde03e0 Mon Sep 17 00:00:00 2001 From: wan Date: Wed, 8 May 2019 10:46:48 +0000 Subject: [PATCH] [FIX] l10n_be_edi: removing tax duplicate If the account was not set on the new move line, a onchange added a new tax line leading to a duplicate Also enforce the company on the tax selection closes odoo/odoo#33250 Signed-off-by: oco-odoo --- addons/l10n_be_edi/models/account_invoice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/l10n_be_edi/models/account_invoice.py b/addons/l10n_be_edi/models/account_invoice.py index 55dc27bf418..642d44acd49 100644 --- a/addons/l10n_be_edi/models/account_invoice.py +++ b/addons/l10n_be_edi/models/account_invoice.py @@ -128,6 +128,7 @@ class AccountInvoice(models.Model): lines_elements = tree.xpath('//cac:InvoiceLine', namespaces=namespaces) for eline in lines_elements: with invoice_form.invoice_line_ids.new() as invoice_line_form: + invoice_line_form.account_id = invoice_line_form.account_id or self.env['account.account'].browse(self.with_context(journal_id=journal_id.id).env['account.invoice.line']._default_account()) # Quantity elements = eline.xpath('cbc:InvoicedQuantity', namespaces=namespaces) quantity = elements and float(elements[0].text) or 1.0 @@ -164,12 +165,11 @@ class AccountInvoice(models.Model): for etax in taxes_elements: elements = etax.xpath('cbc:Percent', namespaces=namespaces) if elements: - tax = self.env['account.tax'].search([('amount', '=', float(elements[0].text)), ('type_tax_use', '=', journal_id.type)], order='sequence ASC', limit=1) + tax = self.env['account.tax'].search([('company_id', '=', self.env.user.company_id.id), ('amount', '=', float(elements[0].text)), ('type_tax_use', '=', journal_id.type)], order='sequence ASC', limit=1) if tax: invoice_line_form.invoice_line_tax_ids.add(tax) - invoice_line_form.account_id = invoice_line_form.account_id or self.env['account.account'].browse(self.with_context(journal_id=journal_id.id).env['account.invoice.line']._default_account()) - return invoice_form.save + return invoice_form.save() @api.model def _get_xml_decoders(self):