From 2f058a49d91dbd2f8187ea0389921d969c3870c2 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 13 Aug 2021 11:11:03 +0200 Subject: [PATCH] [FIX] #2391 l10n_it_fatturapa_out: wrong company in XML --- l10n_it_fatturapa_out/wizard/efattura.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_out/wizard/efattura.py b/l10n_it_fatturapa_out/wizard/efattura.py index 3fa5a6cd6616..a4321f0248e6 100644 --- a/l10n_it_fatturapa_out/wizard/efattura.py +++ b/l10n_it_fatturapa_out/wizard/efattura.py @@ -338,9 +338,18 @@ def to_xml(self, env): content = etree.tostring(root, xml_declaration=True, encoding="utf-8") return content + def _get_company_from_invoices(self, invoices): + company_id = invoices.mapped("company_id") + if len(company_id) > 1: + raise UserError( + _("Invoices %s must belong to the same company.") + % invoices.mapped("number") + ) + return company_id + def __init__(self, wizard, partner_id, invoices, progressivo_invio): self.wizard = wizard - self.company_id = wizard.env.company + self.company_id = self._get_company_from_invoices(invoices) or wizard.env.company self.partner_id = partner_id self.invoices = invoices self.progressivo_invio = progressivo_invio