diff options
| author | Xavier Morel <xmo@odoo.com> | 2020-09-18 06:41:51 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2020-09-18 08:26:28 +0000 |
| commit | f8658f229180a595d69cd6daefeded082c7f64ea (patch) | |
| tree | b563257615f46b80f73a372ea59fd279ea9e39a6 /odoo/addons/base/models/res_users.py | |
| parent | aebe9a76c9b35e84eda1f46bec3ef6da152b1539 (diff) | |
[FIX] base: virtual group fields on users with new default/onchange
* override `onchange` in res.users in order to properly generate and
send the reified group fields alongside the rest: while default_get
sets them up, those fields then get stripped by the onchange
machinery as they don't actually exist on the model
* add a test to check for it
* fix SSF in relation with the new default/onchange system
- because fields may not actually exist on the record,
`record_to_values` needs to `read` the record data rather than
directly access the recordset: the recordset likely will not
know about fake fields
- after the initial onchange has run the form must be filled with
falsy values in case the onchange has not sent defaults for
everything
- on creation, all fields in the form should be considered modified
Task 2341153
closes odoo/odoo#57987
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'odoo/addons/base/models/res_users.py')
| -rw-r--r-- | odoo/addons/base/models/res_users.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/odoo/addons/base/models/res_users.py b/odoo/addons/base/models/res_users.py index e642e4d5c30..903007e4db0 100644 --- a/odoo/addons/base/models/res_users.py +++ b/odoo/addons/base/models/res_users.py @@ -1387,6 +1387,16 @@ class UsersView(models.Model): self._add_reified_groups(group_fields, values) return values + def onchange(self, values, field_name, field_onchange): + field_onchange['groups_id'] = '' + result = super().onchange(values, field_name, field_onchange) + if not field_name: # merged default_get + self._add_reified_groups( + filter(is_reified_group, field_onchange), + result.setdefault('value', {}) + ) + return result + def read(self, fields=None, load='_classic_read'): # determine whether reified groups fields are required, and which ones fields1 = fields or list(self.fields_get()) |
