diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-09-21 08:09:39 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-09-21 08:09:39 +0700 |
| commit | 33166b60a9e0e6b236f39b26e53d925d2790e9db (patch) | |
| tree | 707f6500969d3c7efd277821f8f245df08eaf116 | |
| parent | a5ae0bbfb7bbf07ec444b3eebf62d69df30a0e63 (diff) | |
fix pricelist get id static
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 7effc109..ed722d5e 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -411,8 +411,16 @@ class ProductProduct(models.Model): def _compute_web_price(self): for product in self: - product_pricelist_item = self.env['product.pricelist.item'].search( - [('pricelist_id', '=', 1), ('product_id', '=', product.id)], limit=1) + pricelist_id = self.env.context.get('pricelist') + + domain = [('pricelist_id', '=', pricelist_id or 1), ('product_id', '=', product.id)] + product_pricelist_item = self.env['product.pricelist.item'].search(domain, limit=1) + + if product_pricelist_item.base_pricelist_id: + base_pricelist_id = product_pricelist_item.base_pricelist_id.id + domain = [('pricelist_id', '=', base_pricelist_id), ('product_id', '=', product.id)] + product_pricelist_item = self.env['product.pricelist.item'].search(domain, limit=1) + product.web_price = product_pricelist_item.fixed_price def _compute_stock_vendor(self): |
