Skip to content

Commit

Permalink
[IMP] product_import: currency can be implicit
Browse files Browse the repository at this point in the history
  • Loading branch information
florentx committed Dec 10, 2024
1 parent 04ee2ba commit 71bb0b7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions product_import/wizard/product_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand All @@ -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 or self.env.company).currency_id

product_vals = {
"active": parsed_product.get("active", True),
Expand All @@ -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)
Expand Down

0 comments on commit 71bb0b7

Please sign in to comment.