From aaf9badbceaf683603b4667dd3d29e2784e78e6f Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 12 Mar 2015 13:12:55 +0100 Subject: [PATCH 1/4] [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( From d79a1622bb99338438ab0378643065988b9d6c65 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 26 Mar 2015 11:20:54 +0100 Subject: [PATCH 2/4] [FIX] base: ir_filters: filters not in the language of the user the context of the user must be used in get_filters to take into account the language of the user. opw:630057 --- openerp/addons/base/ir/ir_filters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/addons/base/ir/ir_filters.py b/openerp/addons/base/ir/ir_filters.py index dacacfd3d16..261403b7820 100644 --- a/openerp/addons/base/ir/ir_filters.py +++ b/openerp/addons/base/ir/ir_filters.py @@ -44,10 +44,11 @@ class ir_filters(osv.osv): ``context`` of the matching ``ir.filters``. """ # available filters: private filters (user_id=uid) and public filters (uid=NULL) + context = self.pool['res.users'].context_get(cr, uid) filter_ids = self.search(cr, uid, [('model_id','=',model),('user_id','in',[uid, False])]) my_filters = self.read(cr, uid, filter_ids, - ['name', 'is_default', 'domain', 'context', 'user_id']) + ['name', 'is_default', 'domain', 'context', 'user_id'], context=context) return my_filters def _check_global_default(self, cr, uid, vals, matching_filters, context=None): From f89c4cd78def1ea3f0b3ab4f44dc3308cd30a5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Wed, 7 Jan 2015 12:01:54 +0100 Subject: [PATCH 3/4] [FIX] document : keep order during the search of ir.attachment Backport of 16fa24d52258245af4ee9100666bae6ebe664046 --- addons/document/document.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/document/document.py b/addons/document/document.py index 5384ee0fb18..df12431df7a 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -104,10 +104,13 @@ class document_file(osv.osv): visible_parent_ids = self.pool.get('document.directory').search(cr, uid, [('id', 'in', list(parent_ids))]) # null parents means allowed + orig_ids = ids # save the ids, to keep order ids = parents.get(None,[]) for parent_id in visible_parent_ids: ids.extend(parents[parent_id]) + # sort result according to the original sort ordering + ids = [id for id in orig_ids if id in ids] return len(ids) if count else ids def copy(self, cr, uid, id, default=None, context=None): From 2a0c018043ddcc40074bb46e63bce46f191d459d Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 19 Mar 2015 14:15:33 +0100 Subject: [PATCH 4/4] [FIX] kanban: search more when DataSetStatic When showing a kanban, there is differences between dataset of types: * DataSetStatic: self.view.dataset===self.dataset, their ids attributes are the entire ids list, * DataSet and DataSetSearch: self.view.dataset.ids are the already in the view ids, self.dataset.ids are the last gotten ids. Hence with DataSetStatic dataset, when self.view.dataset.ids.splice(0) is done self.dataset.ids is also emptied. And in the read_slice function, the slice is done on that (now empty) array. This fix removes the splicing of this ids array (which doesn't change a thing since the array is overwritten latter), a _.difference is used to remove eventual duplicates since in the DataSetStatic case, the same array is being concatenated to itself opw-630654 opw-617090 opw-619563 --- addons/web_kanban/static/src/js/kanban.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index bdc0d539d25..60e7f1e6585 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -649,12 +649,12 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({ }, do_show_more: function(evt) { var self = this; - var ids = self.view.dataset.ids.splice(0); + var ids = self.view.dataset.ids.slice(0); return this.dataset.read_slice(this.view.fields_keys.concat(['__last_update']), { 'limit': self.view.limit, 'offset': self.dataset_offset += self.view.limit }).then(function(records) { - self.view.dataset.ids = ids.concat(self.dataset.ids); + self.view.dataset.ids = ids.concat(_.difference(self.dataset.ids, ids)); self.do_add_records(records); self.compute_cards_auto_height(); self.view.postprocess_m2m_tags();