|
@ -39,7 +39,7 @@ class ExceptionRule(models.Model): |
|
|
" are evaluated with several records", |
|
|
" are evaluated with several records", |
|
|
) |
|
|
) |
|
|
domain = fields.Char("Domain") |
|
|
domain = fields.Char("Domain") |
|
|
method = fields.Char("Method", readonly=True) |
|
|
|
|
|
|
|
|
method = fields.Selection(selection=[], string="Method", readonly=True) |
|
|
active = fields.Boolean("Active", default=True) |
|
|
active = fields.Boolean("Active", default=True) |
|
|
code = fields.Text( |
|
|
code = fields.Text( |
|
|
"Python Code", |
|
|
"Python Code", |
|
@ -53,10 +53,7 @@ class ExceptionRule(models.Model): |
|
|
if ( |
|
|
if ( |
|
|
(rule.exception_type == "by_py_code" and not rule.code) |
|
|
(rule.exception_type == "by_py_code" and not rule.code) |
|
|
or (rule.exception_type == "by_domain" and not rule.domain) |
|
|
or (rule.exception_type == "by_domain" and not rule.domain) |
|
|
or ( |
|
|
|
|
|
rule.exception_type == "by_method" |
|
|
|
|
|
and not self._check_method_valid(rule.method, rule.model) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
or (rule.exception_type == "by_method" and not rule.method) |
|
|
): |
|
|
): |
|
|
raise ValidationError( |
|
|
raise ValidationError( |
|
|
_( |
|
|
_( |
|
@ -66,13 +63,6 @@ class ExceptionRule(models.Model): |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
def _check_method_valid(self, method_name, model_name): |
|
|
|
|
|
model = self.env[model_name] |
|
|
|
|
|
method = getattr(model, method_name) |
|
|
|
|
|
if method and callable(method): |
|
|
|
|
|
return True |
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
@api.multi |
|
|
@api.multi |
|
|
def _get_domain(self): |
|
|
def _get_domain(self): |
|
|
""" override me to customize domains according exceptions cases """ |
|
|
""" override me to customize domains according exceptions cases """ |
|
|