From 3dffce34bf80c2a8d8682ef986d6daafa5bb0b7f Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 19 Feb 2020 12:42:23 +0000 Subject: [IMP] fields: log warning for ignored selection When a field is related, defining a selection or selection_add will have no effect and the paramater is ignored. Log a warning and fix all fields badly definied Closes odoo/odoo#45716 closes odoo/odoo#45832 Related: odoo/enterprise#8613 Signed-off-by: Martin Trigaux (mat) --- odoo/fields.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'odoo/fields.py') diff --git a/odoo/fields.py b/odoo/fields.py index 3de87106fd5..64b8083df7c 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -2143,6 +2143,8 @@ class Selection(Field): # We cannot use field.selection or field.selection_add here # because those attributes are overridden by ``_setup_attrs``. if 'selection' in field.args: + if self.related: + _logger.warning("%s: selection attribute will be ignored as the field is related", self) selection = field.args['selection'] if isinstance(selection, list): if ( @@ -2156,6 +2158,8 @@ class Selection(Field): self.selection = selection if 'selection_add' in field.args: + if self.related: + _logger.warning("%s: selection_add attribute will be ignored as the field is related", self) selection_add = field.args['selection_add'] assert isinstance(selection_add, list), \ "%s: selection_add=%r must be a list" % (self, selection_add) -- cgit v1.2.3