From aaf9badbceaf683603b4667dd3d29e2784e78e6f Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 12 Mar 2015 13:12:55 +0100 Subject: [PATCH] [FIX] account: context/domain in move line tree On a line write in a account.move.line tree view, the on_write return all the sibling move lines of the written move line. The lines are then displayed even if they do not match the current search domain. This fix adds the context on the given on_write callback request, and in on_create_write use a on_write_domain in this context to filter the returned ids. fixes #3161, closes #5727 opw-630093 --- addons/account/account_move_line.py | 3 ++- addons/web/static/src/js/view_list_editable.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 8f6618d50ae..e79fde1df8f 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -306,7 +306,8 @@ class account_move_line(osv.osv): if not id: return [] ml = self.browse(cr, uid, id, context=context) - return map(lambda x: x.id, ml.move_id.line_id) + domain = (context or {}).get('on_write_domain', []) + return self.pool.get('account.move.line').search(cr, uid, domain + [['id', 'in', [l.id for l in ml.move_id.line_id]]], context=context) def _balance(self, cr, uid, ids, name, arg, context=None): if context is None: diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 98585fd6757..d1d70068964 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -430,7 +430,8 @@ openerp.web.list_editable = function (instance) { var self = this; var on_write_callback = self.fields_view.arch.attrs.on_write; if (!on_write_callback) { return $.when(); } - return this.dataset.call(on_write_callback, [source_record.get('id')]) + var context = new instance.web.CompoundContext(self.dataset.get_context(), {'on_write_domain': self.dataset.domain}).eval(); + return this.dataset.call(on_write_callback, [source_record.get('id'), context]) .then(function (ids) { return $.when.apply( null, _(ids).map(