|
@ -1,7 +1,8 @@ |
|
|
# Copyright 2019 ACSONE SA/NV |
|
|
# Copyright 2019 ACSONE SA/NV |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|
|
|
|
|
|
|
|
from odoo import fields, models |
|
|
|
|
|
|
|
|
from odoo import fields, models, api, _ |
|
|
|
|
|
from odoo.exceptions import ValidationError |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ActionsReportSubstitutionRule(models.Model): |
|
|
class ActionsReportSubstitutionRule(models.Model): |
|
@ -24,5 +25,23 @@ class ActionsReportSubstitutionRule(models.Model): |
|
|
string="Substitution Report Action", |
|
|
string="Substitution Report Action", |
|
|
required=True, |
|
|
required=True, |
|
|
ondelete="cascade", |
|
|
ondelete="cascade", |
|
|
domain="[('model', '=', model)]" |
|
|
|
|
|
|
|
|
domain="[('model', '=', model)]", |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
@api.constrains('substitution_action_report_id', 'action_report_id') |
|
|
|
|
|
def _check_substitution_infinite_loop(self): |
|
|
|
|
|
def _check_infinite_loop(original_report, substitution_report): |
|
|
|
|
|
if original_report == substitution_report: |
|
|
|
|
|
raise ValidationError(_("Substitution infinite loop detected")) |
|
|
|
|
|
for ( |
|
|
|
|
|
substitution_rule |
|
|
|
|
|
) in substitution_report.action_report_substitution_rule_ids: |
|
|
|
|
|
_check_infinite_loop( |
|
|
|
|
|
original_report, |
|
|
|
|
|
substitution_rule.substitution_action_report_id, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
for rec in self: |
|
|
|
|
|
_check_infinite_loop( |
|
|
|
|
|
rec.action_report_id, rec.substitution_action_report_id |
|
|
) |
|
|
) |