From 4f3a8110a5988c59dbbb678e50cb857daabe678d Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 9 Dec 2024 10:22:57 +0100 Subject: [PATCH] [IMP] product_import: currency can be implicit --- product_import/wizard/product_import.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/product_import/wizard/product_import.py b/product_import/wizard/product_import.py index cbf1c13002..24accb1f96 100644 --- a/product_import/wizard/product_import.py +++ b/product_import/wizard/product_import.py @@ -154,7 +154,9 @@ def _prepare_product(self, parsed_product, chatter_msg, seller=None): # Important: barcode is unique key of product.template model # So records product.product are created with company_id=False. # Only the pricelist (product.supplierinfo) is company-specific. - product_company_id = self.env.context.get("product_company_id", False) + import_company = self.env["res.company"].browse( + self.env.context.get("product_company_id") + ) if not parsed_product["barcode"]: chatter_msg.append( _("Cannot import product without barcode: %s") % (parsed_product,) @@ -166,9 +168,12 @@ def _prepare_product(self, parsed_product, chatter_msg, seller=None): .search([("barcode", "=", parsed_product["barcode"])], limit=1) ) uom = self._bdimport._match_uom(parsed_product["uom"], chatter_msg) - currency = self._bdimport._match_currency( - parsed_product["currency"], chatter_msg - ) + if parsed_product["currency"]: + currency = self._bdimport._match_currency( + parsed_product["currency"], chatter_msg + ) + else: + currency = import_company.currency_id product_vals = { "active": parsed_product.get("active", True), @@ -187,7 +192,7 @@ def _prepare_product(self, parsed_product, chatter_msg, seller=None): "price": parsed_product["price"], "currency_id": currency.id, "min_qty": parsed_product["min_qty"], - "company_id": product_company_id, + "company_id": import_company.id, "delay": parsed_product.get("sale_delay", 0), } product_vals["seller_ids"] = self._prepare_supplierinfo(seller_info, product)