diff --git a/easy_my_coop/__openerp__.py b/easy_my_coop/__openerp__.py index 8886dfd..8dd05d7 100644 --- a/easy_my_coop/__openerp__.py +++ b/easy_my_coop/__openerp__.py @@ -4,7 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Easy My Coop", - "version": "9.1.0.0.1", + "version": "9.1.0.0.2", "depends": ["base", "sale", "purchase", diff --git a/easy_my_coop/migrations/9.1.0.0.2/pre-migration.py b/easy_my_coop/migrations/9.1.0.0.2/pre-migration.py new file mode 100644 index 0000000..1eee511 --- /dev/null +++ b/easy_my_coop/migrations/9.1.0.0.2/pre-migration.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +def migrate(cr, version): + if not version: + return + + cr.execute("UPDATE res_company " + "SET internal_rules_approval_required = FALSE " + "WHERE display_internal_rules_approval = FALSE") + cr.execute("UPDATE res_company " + "SET data_policy_approval_required = FALSE " + "WHERE display_data_policy_approval = FALSE") + cr.execute("UPDATE res_company " + "SET financial_risk_approval_required = FALSE " + "WHERE display_financial_risk_approval = FALSE") diff --git a/easy_my_coop/models/company.py b/easy_my_coop/models/company.py index 1ba8a89..83bc62f 100644 --- a/easy_my_coop/models/company.py +++ b/easy_my_coop/models/company.py @@ -95,3 +95,18 @@ class ResCompany(models.Model): def onchange_financial_risk_approval_required(self): if self.financial_risk_approval_required: self.display_financial_risk_rules_approval = True + + _sql_constraints = [( + 'approval_constraint', + """CHECK (((internal_rules_approval_required=FALSE + AND display_internal_rules_approval=FALSE) + OR display_internal_rules_approval=TRUE) + AND ((data_policy_approval_required=FALSE + AND display_data_policy_approval=FALSE) + OR display_data_policy_approval=TRUE) + AND ((financial_risk_approval_required=FALSE + AND display_financial_risk_approval=FALSE) + OR display_financial_risk_approval=TRUE)) + """, + "Approval can't be mandatory and not displayed." + )]