From 652ebb96e5a9b8bedf0879691fc726e619d5de78 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Mon, 30 Sep 2019 13:10:29 +0000 Subject: [PATCH] [FIX] tests: correctly handle invisible fields in form proxy The form proxy will raise an error if a required field is not filled, even when the web client would let it pass through. Indeed, the web client (correctly) assumes that a user cannot fill in an invisible field and that something will probably be done on the server to handle that (e.g. an override of the write/create or simply a command-handling code by the ORM). Since invisible fields do not even get a widget instaciated for them, no validation takes place whatsoever. Since it is sometimes (for obscure reasons) necessary to include all kinds of invisible fields in tree view (e.g. to get correct values for related stored fields, somehow), it is possible that required fields in a view are in fact not really required since they are ignored by the web client and then correctly handled/modified server-side. This commit adapts the test proxies to behave similarly to the web client (since that is, after all, the goal of these proxies) and to ignore invisible fields when validating views. closes odoo/odoo#37432 Signed-off-by: Damien Bouvy (dbo) --- odoo/tests/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 9350ff49327..08d1b28d4c1 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -1539,7 +1539,7 @@ class Form(object): for f in fields: descr = fields[f] v = self._values[f] - if self._get_modifier(f, 'required') and not descr['type'] == 'boolean': + if self._get_modifier(f, 'required') and not (descr['type'] == 'boolean' or self._get_modifier(f, 'invisible')): assert v is not False, "{} is a required field".format(f) # skip unmodified fields @@ -1764,7 +1764,7 @@ class O2MForm(Form): values._changed.update(self._changed) for f in self._view['fields']: - if self._get_modifier(f, 'required'): + if self._get_modifier(f, 'required') and not (self._get_modifier(f, 'column_invisible') or self._get_modifier(f, 'invisible')): assert self._values[f] is not False, "{} is a required field".format(f) return values