[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
This commit is contained in:
Nicolas Lempereur
2015-03-26 08:59:23 +01:00
parent 881c10b8ec
commit aaf9badbce
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -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:
@@ -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(