Skip to content

Commit

Permalink
Merge PR OCA#1507 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jan 30, 2024
2 parents 70ff1f2 + 0b34af4 commit 7b0ebee
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions product_supplierinfo_for_customer/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,24 @@ def _select_customerinfo(
domain = self._prepare_domain_customerinfo(params)
params["domain"] = domain

customers = self._prepare_customers(params)
customerinfos = self._prepare_customers(params)
precision = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)

if quantity is not None:
customers = self._customers_filter_by_quantity(
customers, quantity=quantity, uom_id=uom_id, precision=precision
customerinfos = self._customers_filter_by_quantity(
customerinfos, quantity=quantity, uom_id=uom_id, precision=precision
)
if customerinfos:
customer = customerinfos[0].name
customerinfos = customerinfos.filtered(
lambda x, name=customer: x.name == name
)
if customers:
customer_name = customers[0].name
customers = customers.filtered(lambda x, name=customer_name: x.name == name)

# Prefer matching specific variants over templates if possible
variant_res = customers.filtered(lambda x: x.product_id)
variant_res = customerinfos.filtered(lambda x: x.product_id)
if variant_res:
customers = variant_res
customerinfos = variant_res

return customers.sorted("price")[:1]
return customerinfos.sorted("price")[:1]

0 comments on commit 7b0ebee

Please sign in to comment.