Browse Source

Merge PR #2075 into 12.0

Signed-off-by dreispt
12.0-mig-module_prototyper_last
OCA-git-bot 4 years ago
parent
commit
72127aafb0
  1. 17
      onchange_helper/models/base.py

17
onchange_helper/models/base.py

@ -51,15 +51,18 @@ class Base(models.AbstractModel):
else:
# We get default values, they may be used in onchange
record_values = self.default_get(self._fields.keys())
for field in self._fields:
if field not in all_values:
all_values[field] = record_values.get(field, False)
for fn, field in self._fields.items():
if not field.related and fn not in all_values: # related fields are False
all_values[fn] = record_values.get(fn, False)
new_values = {}
for field in onchange_fields:
onchange_values = self.onchange(all_values, field, onchange_specs)
new_values.update(self._get_new_values(values, onchange_values))
all_values.update(new_values)
with self.env.do_in_onchange(): # avoid cache issues with related fields!
new = self.new(all_values)
for field in onchange_fields:
onchange_values = new.onchange(all_values, field, onchange_specs)
new_values.update(self._get_new_values(values, onchange_values))
all_values.update(new_values)
return {
f: v

Loading…
Cancel
Save