mirror of
https://github.com/NaN-tic/trytond-product_cost_plan.git
synced 2023-12-14 03:03:11 +01:00
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
|
@classmethod
|
||||||
def delete(cls, plans):
|
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):
|
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):
|
class PlanBOM(ModelSQL, ModelView):
|
||||||
|
|
Loading…
Reference in a new issue