From 78146822a579149a08c4b93703eca49f34bee0b3 Mon Sep 17 00:00:00 2001 From: Juanjo Garcia Date: Wed, 2 Oct 2019 10:54:33 +0200 Subject: [PATCH] Add Warning.check() to UserWarning. --- plan.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plan.py b/plan.py index 0e38feb..3e540e1 100644 --- a/plan.py +++ b/plan.py @@ -204,8 +204,10 @@ class Plan(ModelSQL, ModelView): ('plan', 'in', [p.id for p in plans]), ]) if product_lines: - UserWarning('remove_product_lines', - gettext('product_cost_plan.product_lines_will_be_removed')) + key = 'task_product_lines_will_be_removed.%d' % product_lines[0].id + if Warning.check(key): + raise UserWarning('remove_product_lines', + gettext('product_cost_plan.product_lines_will_be_removed')) ProductLine.delete(product_lines) with Transaction().set_context(reset_costs=True): @@ -739,10 +741,12 @@ class PlanCost(ModelSQL, ModelView): if not Transaction().context.get('reset_costs', False): for cost in costs: if cost.system: - raise UserWarning('delete_system_cost', - gettext('product_cost_plan.delete_system_cost', - cost=cost.rec_name, - plan=cost.plan.rec_name)) + key = 'task_delete_system_cost.%d' % cost.id + if Warning.check(key): + raise UserWarning('delete_system_cost', + gettext('product_cost_plan.delete_system_cost', + cost=cost.rec_name, + plan=cost.plan.rec_name)) super(PlanCost, cls).delete(costs)