From ef5d9f895d4ea430815110028d6a7b6ba5741fe1 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 26 Nov 2025 23:55:59 +0100 Subject: [PATCH 1/2] [FIX] l10n_fr_account_invoice_import_facturx: set siren/siret on partner created from 'create or update wizard' --- .../wizard/account_invoice_import.py | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/l10n_fr_account_invoice_import_facturx/wizard/account_invoice_import.py b/l10n_fr_account_invoice_import_facturx/wizard/account_invoice_import.py index 7b582282b..3c0248fde 100644 --- a/l10n_fr_account_invoice_import_facturx/wizard/account_invoice_import.py +++ b/l10n_fr_account_invoice_import_facturx/wizard/account_invoice_import.py @@ -2,7 +2,7 @@ # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models +from odoo import api, models class AccountInvoiceImport(models.TransientModel): @@ -23,3 +23,26 @@ def prepare_facturx_xpath_dict(self): "/ram:ID[@schemeID='0002']" ] return xpathd + + # If one day we have a module l10n_fr_account_invoice_import + # we could move the inherit of _prepare_new_partner_context() there + @api.model + def _prepare_create_invoice_no_partner(self, parsed_inv, import_config, vals): + res = super()._prepare_create_invoice_no_partner( + parsed_inv, import_config, vals + ) + if ( + vals.get("import_partner_data") + and isinstance(vals["import_partner_data"], dict) + and parsed_inv.get("partner") + ): + if parsed_inv["partner"].get("siren"): + vals["import_partner_data"]["siren"] = parsed_inv["partner"]["siren"] + elif parsed_inv["partner"].get("siret"): + vals["import_partner_data"]["siren"] = parsed_inv["partner"]["siret"][ + :9 + ] + vals["import_partner_data"]["nic"] = parsed_inv["partner"]["siret"][ + 9:14 + ] + return res From d8e2d8f54f3c3fe2859537cc8fb56cedb86adebe Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 27 Nov 2025 00:00:27 +0100 Subject: [PATCH 2/2] [FIX] l10n_fr_business_document_import: _check_company() updated to changes in base_business_document_import --- .../models/business_document_import.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/l10n_fr_business_document_import/models/business_document_import.py b/l10n_fr_business_document_import/models/business_document_import.py index 124b9220b..29fd9d1b9 100644 --- a/l10n_fr_business_document_import/models/business_document_import.py +++ b/l10n_fr_business_document_import/models/business_document_import.py @@ -64,10 +64,14 @@ def _check_company( ): if not company_dict: company_dict = {} - rco = self.env["res.company"] if company is None: - if self._context.get("force_company"): - company = rco.browse(self._context["force_company"]) + if ( + self._context.get("allowed_company_ids") + and len(self._context["allowed_company_ids"]) == 1 + ): + company = self.env["res.company"].browse( + self._context["allowed_company_ids"][0] + ) else: company = self.env.company siren = False @@ -79,7 +83,7 @@ def _check_company( if siren and siren_is_valid(siren): if company.siren: if company.siren != siren: - raise self.user_error_wrap( + self.user_error_wrap( "_check_company", company_dict, _( @@ -100,9 +104,9 @@ def _check_company( and company.country_id.code in self.env["res.company"]._get_france_country_codes() ): - chatter_msg.append( - _("Missing SIRET on company '%s'.") % company.display_name - ) + msg = _("Missing SIRET on company '%s'.") % company.display_name + if msg not in chatter_msg: + chatter_msg.append(msg) return super()._check_company( company_dict, chatter_msg, company=company, raise_exception=raise_exception )