From f3de712d7624d9385b098c6657a660fbce3c0aad Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Fri, 11 Jan 2019 16:03:44 +0000 Subject: [PATCH] [FIX] ir_model: add constraint on domain field Previous to this commit, if one were to create an ir.model.field with a poorly constructed domain (read: SyntaxError), the server would properly send an error message stating that an Error occurred, however this would be too late as the registry with the bad code would have already been reloaded, this meant that the registry would be left in an unstable state (read: crashed). With this commit, a constraint on the domain is added so that we confirm that the code in the domain field is properly constructed, thus no need to reload the registry and therefore no crash. closes odoo/odoo#30157 --- odoo/addons/base/ir/ir_model.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odoo/addons/base/ir/ir_model.py b/odoo/addons/base/ir/ir_model.py index ec58bf422ac..fd63d0c590d 100644 --- a/odoo/addons/base/ir/ir_model.py +++ b/odoo/addons/base/ir/ir_model.py @@ -287,6 +287,11 @@ class IrModelFields(models.Model): raise UserError(_("The Selection Options expression is not a valid Pythonic expression." "Please provide an expression in the [('key','Label'), ...] format.")) + @api.constrains('domain') + def _check_domain(self): + for field in self: + safe_eval(field.domain or '[]') + @api.constrains('name', 'state') def _check_name(self): for field in self: