From 72928f13316da9e92ff53618eec2d044ae1eeee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80ngel=20=C3=80lvarez?= Date: Tue, 10 Mar 2020 11:59:58 +0100 Subject: [PATCH] Make plan not required on product lines, and creat function to return all products to create bom correctly --- plan.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plan.py b/plan.py index bd00bae..7f6ff28 100644 --- a/plan.py +++ b/plan.py @@ -404,8 +404,17 @@ class Plan(ModelSQL, ModelView): pool = Pool() Uom = pool.get('product.uom') + def _get_all_inputs(lines): + lines = [x for x in lines] + for line in lines: + if not line.children: + continue + lines += _get_all_inputs(line.children) + return lines + inputs = {} - for line in self.products: + lines = _get_all_inputs(self.products) + for line in lines: if not line.product: continue input_ = self._get_input_line(line) @@ -502,7 +511,7 @@ class PlanProductLine(ModelSQL, ModelView, tree(separator='/')): parent = fields.Many2One('product.cost.plan.product_line', 'Parent') children = fields.One2Many('product.cost.plan.product_line', 'parent', 'Children') - plan = fields.Many2One('product.cost.plan', 'Plan', required=True, + plan = fields.Many2One('product.cost.plan', 'Plan', required=False, ondelete='CASCADE') product = fields.Many2One('product.product', 'Product', domain=[ ('type', '!=', 'service'),