Add Warning.check() to UserWarning.

This commit is contained in:
Juanjo Garcia 2019-10-02 10:54:33 +02:00
parent 066c77501e
commit 78146822a5
1 changed files with 10 additions and 6 deletions

16
plan.py
View File

@ -204,8 +204,10 @@ class Plan(ModelSQL, ModelView):
('plan', 'in', [p.id for p in plans]), ('plan', 'in', [p.id for p in plans]),
]) ])
if product_lines: if product_lines:
UserWarning('remove_product_lines', key = 'task_product_lines_will_be_removed.%d' % product_lines[0].id
gettext('product_cost_plan.product_lines_will_be_removed')) if Warning.check(key):
raise UserWarning('remove_product_lines',
gettext('product_cost_plan.product_lines_will_be_removed'))
ProductLine.delete(product_lines) ProductLine.delete(product_lines)
with Transaction().set_context(reset_costs=True): with Transaction().set_context(reset_costs=True):
@ -739,10 +741,12 @@ class PlanCost(ModelSQL, ModelView):
if not Transaction().context.get('reset_costs', False): if not Transaction().context.get('reset_costs', False):
for cost in costs: for cost in costs:
if cost.system: if cost.system:
raise UserWarning('delete_system_cost', key = 'task_delete_system_cost.%d' % cost.id
gettext('product_cost_plan.delete_system_cost', if Warning.check(key):
cost=cost.rec_name, raise UserWarning('delete_system_cost',
plan=cost.plan.rec_name)) gettext('product_cost_plan.delete_system_cost',
cost=cost.rec_name,
plan=cost.plan.rec_name))
super(PlanCost, cls).delete(costs) super(PlanCost, cls).delete(costs)