Remove lines that have not plan
This commit is contained in:
parent
b92142b0db
commit
153af1ecd8
15
plan.py
15
plan.py
|
@ -449,8 +449,21 @@ class Plan(DeactivableMixin, ModelSQL, ModelView):
|
|||
|
||||
@classmethod
|
||||
def delete(cls, plans):
|
||||
pool = Pool()
|
||||
CostLine = pool.get('product.cost.plan.cost')
|
||||
Line = pool.get('product.cost.plan.product_line')
|
||||
|
||||
to_delete = []
|
||||
to_delete2 = []
|
||||
for plan in plans:
|
||||
to_delete += plan.costs
|
||||
to_delete2 += [line for line in plan.all_products
|
||||
if line.plan is None]
|
||||
with Transaction().set_context(reset_costs=True):
|
||||
super(Plan, cls).delete(plans)
|
||||
CostLine.delete(to_delete)
|
||||
Line.delete(to_delete2)
|
||||
|
||||
super(Plan, cls).delete(plans)
|
||||
|
||||
|
||||
class PlanBOM(ModelSQL, ModelView):
|
||||
|
|
Loading…
Reference in New Issue