From 348af86ab2ff5b0c5429b9e464c4a37f183b2028 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Wed, 29 Sep 2021 13:13:49 -0700 Subject: [PATCH] [FIX] purchase_by_sale_history_mrp: BOM for `product.template` that doesn't have any `product_variant_ids` --- .../wizard/purchase_by_sale_history.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/purchase_by_sale_history_mrp/wizard/purchase_by_sale_history.py b/purchase_by_sale_history_mrp/wizard/purchase_by_sale_history.py index 56da00d3..151f5529 100644 --- a/purchase_by_sale_history_mrp/wizard/purchase_by_sale_history.py +++ b/purchase_by_sale_history_mrp/wizard/purchase_by_sale_history.py @@ -34,6 +34,10 @@ class PurchaseBySaleHistory(models.TransientModel): raise UserError('You cannot have two identical finished goods being created ' 'from different ratios/BoMs. Finished Product ID: %s' % (pid, )) product_ids_dict[pid] = {'ratio': ratio} + if not product_ids_dict: + # this indicates that the BOM is for a product.template without any product variants + # if there are no variants, then it couldn't have been sold + return 0.0 history = self._sale_history(product_ids_dict.keys()) products = product_model.browse(product_ids_dict.keys())