Browse Source

[FIX] Mandatory field not displayed

Replace the api.onchange for an sql constraint.
Mandatory configuration approval fields must be displayed now.
pull/31/head
Elouan Le Bars 5 years ago
parent
commit
f406155d5c
  1. 2
      easy_my_coop/__openerp__.py
  2. 15
      easy_my_coop/migrations/9.1.0.0.2/pre-migration.py
  3. 15
      easy_my_coop/models/company.py

2
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",

15
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")

15
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."
)]
Loading…
Cancel
Save