diff options
| author | Raphael Collet <rco@odoo.com> | 2019-10-28 14:59:27 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-08-20 13:39:04 +0000 |
| commit | 3e91fa1dbf9056f1557ff7a747ba3407e851b18e (patch) | |
| tree | 83026623a533cedb334a35c0b128b7bede175622 /odoo/fields.py | |
| parent | 38b7462dcf7541bbcb51ac75cc1f7b6715f13ace (diff) | |
[FIX] core: first onchange on new one2many line
Consider models `M` and `L`, with a one2many field `M.l_ids` with
inverse `L.m_id`. Consider also a computed field `L.foo` that depends
on `L.m_id`.
The field `L.foo` is not computed correctly by `onchange` on a new line
in the form view of `M`: its value is forced to `False` because it has
no default, and is not recomputed by `onchange` since the field `L.m_id`
is never triggered an `onchange`.
Modify the method `onchange` to not force fields without a default to
`False`, and return all fields.
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/odoo/fields.py b/odoo/fields.py index 46d65d4e6f4..2838bfbef56 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -963,7 +963,14 @@ class Field(MetaField('DummyField', (object,), {})): self.compute_value(recs) except (AccessError, MissingError): self.compute_value(record) - value = env.cache.get(record, self) + try: + value = env.cache.get(record, self) + except CacheMiss: + if self.readonly: + raise + # fallback to null value if compute gives nothing + value = self.convert_to_cache(False, record, validate=False) + env.cache.set(record, self, value) elif self.type == 'many2one' and self.delegate and not record.id: # parent record of a new record: new record, with the same |
