diff --git a/ssi_risk_analysis/models/risk_analysis_worksheet.py b/ssi_risk_analysis/models/risk_analysis_worksheet.py index 9163d4c..e77825c 100644 --- a/ssi_risk_analysis/models/risk_analysis_worksheet.py +++ b/ssi_risk_analysis/models/risk_analysis_worksheet.py @@ -2,9 +2,9 @@ # Copyright 2022 PT. Simetri Sinergi Indonesia # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0-standalone.html). -from odoo import api, fields, models +from odoo import _, api, fields, models from odoo.tools.safe_eval import safe_eval -from odoo.exceptions import ValidationError +from odoo.exceptions import Warning as UserError class RiskAnalysisWorksheet(models.Model): @@ -318,4 +318,13 @@ def _check_item_id(self): ('id', '!=', record.id) ]) if items: - raise ValidationError("The risk item '%s - %s' is already used." % (record.item_id.name, record.risk_analysis_id.name)) + error_message = _( + """ + Context: You can not select the same risk item + Database ID: %s + Problem: Risk item: %s is used + Solution: Use another risk item + """ + % (record.id, record.item_id.name,) + ) + raise UserError(error_message)