summaryrefslogtreecommitdiff
path: root/fixco_custom/models/reordering_rule.py
diff options
context:
space:
mode:
Diffstat (limited to 'fixco_custom/models/reordering_rule.py')
-rw-r--r--fixco_custom/models/reordering_rule.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/fixco_custom/models/reordering_rule.py b/fixco_custom/models/reordering_rule.py
index 787875b..107d40b 100644
--- a/fixco_custom/models/reordering_rule.py
+++ b/fixco_custom/models/reordering_rule.py
@@ -42,11 +42,14 @@ class ReorderingRule(models.Model):
qty_purchase = max(qty_purchase, 0.0)
- pricelist = self.env['purchase.pricelist'].search([
- ('product_id', '=', stock.product_id.id),
- ('vendor_id', '=', stock.vendor_id.id)
+ pricelist = self.env['product.supplierinfo'].search([
+ ('product_tmpl_id', '=', stock.product_id.product_tmpl_id.id),
+ ('name', '=', stock.vendor_id.id)
], limit=1)
+ if not pricelist:
+ raise UserError("No pricelist found for product %s and vendor %s" % (stock.product_id.name, stock.vendor_id.name))
+
price = pricelist.price if pricelist else 0.0
subtotal = qty_purchase * price