mirror of
https://github.com/NaN-tic/trytond-product_cost_plan.git
synced 2023-12-14 03:03:11 +01:00
Compare commits
2 commits
cae1023351
...
d08a80d270
Author | SHA1 | Date | |
---|---|---|---|
|
d08a80d270 | ||
|
8d03eff9cc |
1 changed files with 14 additions and 3 deletions
17
plan.py
17
plan.py
|
@ -449,12 +449,20 @@ class Plan(DeactivableMixin, ModelSQL, ModelView):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete(cls, plans):
|
def delete(cls, plans):
|
||||||
CostLine = Pool().get('product.cost.plan.cost')
|
pool = Pool()
|
||||||
|
CostLine = pool.get('product.cost.plan.cost')
|
||||||
|
Line = pool.get('product.cost.plan.product_line')
|
||||||
|
|
||||||
to_delete = []
|
to_delete = []
|
||||||
|
to_delete2 = []
|
||||||
for plan in plans:
|
for plan in plans:
|
||||||
to_delete += plan.costs
|
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):
|
||||||
CostLine.delete(to_delete)
|
CostLine.delete(to_delete)
|
||||||
|
Line.delete(to_delete2)
|
||||||
|
|
||||||
super(Plan, cls).delete(plans)
|
super(Plan, cls).delete(plans)
|
||||||
|
|
||||||
|
|
||||||
|
@ -547,8 +555,11 @@ class PlanProductLine(ModelSQL, ModelView, tree(separator='/')):
|
||||||
|
|
||||||
@fields.depends('children', 'product', 'plan', '_parent_plan.uom')
|
@fields.depends('children', 'product', 'plan', '_parent_plan.uom')
|
||||||
def on_change_with_uom_category(self, name=None):
|
def on_change_with_uom_category(self, name=None):
|
||||||
if self.children and self.children[0].uom:
|
if self.children:
|
||||||
return self.children[0].uom.category.id
|
uoms = set([child.uom.category for child in self.children
|
||||||
|
if child.uom])
|
||||||
|
if len(uoms) == 1:
|
||||||
|
return list(uoms)[0].id
|
||||||
elif self.product:
|
elif self.product:
|
||||||
return self.product.default_uom.category.id
|
return self.product.default_uom.category.id
|
||||||
elif self.plan and self.plan.uom:
|
elif self.plan and self.plan.uom:
|
||||||
|
|
Loading…
Reference in a new issue