From 82ccd740c22b267c3a3d8c5d2cae696d6ce96c87 Mon Sep 17 00:00:00 2001 From: percyhibou Date: Mon, 10 Oct 2022 16:19:46 +0000 Subject: [PATCH] [IMP] project_exception: check for 'project_id' in vals H11045 --- project_exception/models/project.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/project_exception/models/project.py b/project_exception/models/project.py index de2e2fae..aadf60e9 100644 --- a/project_exception/models/project.py +++ b/project_exception/models/project.py @@ -1,6 +1,7 @@ # Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. -from odoo import api, models, fields +from odoo import api, models, fields, _ +from odoo.exceptions import UserError class ExceptionRule(models.Model): @@ -41,11 +42,13 @@ class Task(models.Model): return 'task_ids' def write(self, vals): - if not vals.get('ignore_exception'): + if not vals.get('ignore_exception') and 'stage_id' in vals and 'project_id' not in vals: for task in self: if task.detect_exceptions(): - return self._popup_exceptions() - return super().write(vals) + raise UserError(_('Exceptions were detected.')) + res = super().write(vals) + self.detect_exceptions() + return res @api.model def _get_popup_action(self):