Skip to content

Commit

Permalink
[FIX] base: corrected automated action onchange and write
Browse files Browse the repository at this point in the history
When having an automated action which
triggered upon changing a field to write on another
(no python code, but operatiing with ir.server.object.lines)

Before this commit, the onchange was not performed.
This was because there was no active id
(in fact the code did not take object(<NewId>) into consideration)

After this commit, the onchange is performed.

OPW 801424
  • Loading branch information
kebeclibre authored and nim-odoo committed Jan 9, 2018
1 parent 849d8ff commit 1ad8867
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion odoo/addons/base/ir/ir_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,13 @@ def run_action_object_write(self, action, eval_context=None):
else:
ref_id = int(ref)

self.env[model].browse(ref_id).write(res)
if self._context.get('onchange_self'):
record_cached = self._context['onchange_self']
for field, new_value in res.iteritems():
record_cached[field] = new_value
else:
self.env[model].browse(ref_id).write(res)


@api.model
def run_action_object_create(self, action, eval_context=None):
Expand Down Expand Up @@ -975,6 +981,8 @@ def run(self):

elif hasattr(self, 'run_action_%s' % action.state):
active_id = self._context.get('active_id')
if not active_id and self._context.get('onchange_self'):
active_id = self._context['onchange_self']._origin.id
active_ids = self._context.get('active_ids', [active_id] if active_id else [])
for active_id in active_ids:
# run context dedicated to a particular active_id
Expand Down

0 comments on commit 1ad8867

Please sign in to comment.