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