Skip to content

Commit

Permalink
[FIX] product_ux: fix in searching price lists
Browse files Browse the repository at this point in the history
closes #571

Signed-off-by: Bruno Zanotti <bz@adhoc.com.ar>
  • Loading branch information
lef-adhoc authored and bruno-zanotti committed Jan 22, 2024
1 parent d46b14d commit 699aee2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion product_ux/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,15 @@ class ProductProduct(models.Model):

@api.depends_context('pricelist', 'quantity', 'uom', 'date', 'no_variant_attributes_price_extra')
def _compute_product_pricelist_price(self):
context = dict(self._context)
if 'pricelist' in context:
id_pricelist = next((x for x in context['pricelist'] if isinstance(x, int)), None)
if id_pricelist is None:
pricelist_name_search = self.env['product.pricelist'].name_search(
context['pricelist'][0], operator="ilike", limit=1
)
context['pricelist'] = pricelist_name_search[0][0] if pricelist_name_search else False
else:
context['pricelist'] = id_pricelist
for product in self:
product.pricelist_price = product._get_contextual_price()
product.pricelist_price = product.with_context(context)._get_contextual_price()
12 changes: 11 additions & 1 deletion product_ux/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,15 @@ class ProductTemplate(models.Model):

@api.depends_context('pricelist', 'quantity', 'uom', 'date', 'no_variant_attributes_price_extra')
def _compute_product_pricelist_price(self):
context = dict(self._context)
if 'pricelist' in context:
id_pricelist = next((x for x in context['pricelist'] if isinstance(x, int)), None)
if id_pricelist is None:
pricelist_name_search = self.env['product.pricelist'].name_search(
context['pricelist'][0], operator="ilike", limit=1
)
context['pricelist'] = pricelist_name_search[0][0] if pricelist_name_search else False
else:
context['pricelist'] = id_pricelist
for product in self:
product.pricelist_price = product._get_contextual_price()
product.pricelist_price = product.with_context(context)._get_contextual_price()

0 comments on commit 699aee2

Please sign in to comment.