-
-
Save hugho-ad/37cd3b908d643704b588625a0af41734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/product_pricelist_supplierinfo/models/product_pricelist.py b/product_pricelist_supplierinfo/models/product_pricelist.py | |
index ac66bd1d..f1ad8a31 100644 | |
--- a/product_pricelist_supplierinfo/models/product_pricelist.py | |
+++ b/product_pricelist_supplierinfo/models/product_pricelist.py | |
@@ -5,32 +5,6 @@ | |
from odoo import fields, models | |
-class ProductPricelist(models.Model): | |
- _inherit = "product.pricelist" | |
- | |
- def _compute_price_rule(self, products, qty, uom=None, date=False, **kwargs): | |
- """Recompute price after calling the atomic super method for | |
- getting proper prices when based on supplier info. | |
- """ | |
- rule_obj = self.env["product.pricelist.item"] | |
- result = super()._compute_price_rule(products, qty, uom, date, **kwargs) | |
- # Make sure all rule records are fetched at once at put in cache | |
- rule_obj.browse(x[1] for x in result.values()).mapped("price_discount") | |
- context = self.env.context | |
- for product in products: | |
- rule = rule_obj.browse(result[product.id][1]) | |
- if rule.compute_price == "formula" and rule.base == "supplierinfo": | |
- result[product.id] = ( | |
- product.sudo()._get_supplierinfo_pricelist_price( | |
- rule, | |
- date=date or context.get("date", fields.Date.today()), | |
- quantity=qty, | |
- ), | |
- rule.id, | |
- ) | |
- return result | |
- | |
- | |
class ProductPricelistItem(models.Model): | |
_inherit = "product.pricelist.item" | |
@@ -46,3 +20,10 @@ class ProductPricelistItem(models.Model): | |
string="Supplier filter", | |
help="Only match prices from the selected supplier", | |
) | |
+ | |
+ def _compute_price(self, product, quantity, uom, date, currency=None): | |
+ result = super()._compute_price(product, quantity, uom, date, currency) | |
+ if self.compute_price == "formula" and self.base == "supplierinfo": | |
+ result = product.sudo()._get_supplierinfo_pricelist_price( | |
+ self, date=date or context.get("date", fields.Date.today()), quantity=quantity) | |
+ return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment