From 37125e826bc16962e29c67e7ccef8ce75e53197f Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 28 Jul 2014 10:10:09 +0200 Subject: [PATCH 01/17] [ADD] advanced_filters --- advanced_filters/__init__.py | 22 ++ advanced_filters/__openerp__.py | 78 +++++++ advanced_filters/model/__init__.py | 21 ++ advanced_filters/model/ir_filters.py | 149 +++++++++++++ .../static/src/css/advanced_filters.css | 14 ++ advanced_filters/static/src/img/icon.png | Bin 0 -> 16070 bytes .../static/src/js/advanced_filters.js | 209 ++++++++++++++++++ advanced_filters/view/ir_filters.xml | 44 ++++ advanced_filters/wizard/__init__.py | 21 ++ .../ir_filters_combine_with_existing.py | 87 ++++++++ .../ir_filters_combine_with_existing.xml | 21 ++ 11 files changed, 666 insertions(+) create mode 100644 advanced_filters/__init__.py create mode 100644 advanced_filters/__openerp__.py create mode 100644 advanced_filters/model/__init__.py create mode 100644 advanced_filters/model/ir_filters.py create mode 100644 advanced_filters/static/src/css/advanced_filters.css create mode 100644 advanced_filters/static/src/img/icon.png create mode 100644 advanced_filters/static/src/js/advanced_filters.js create mode 100644 advanced_filters/view/ir_filters.xml create mode 100644 advanced_filters/wizard/__init__.py create mode 100644 advanced_filters/wizard/ir_filters_combine_with_existing.py create mode 100644 advanced_filters/wizard/ir_filters_combine_with_existing.xml diff --git a/advanced_filters/__init__.py b/advanced_filters/__init__.py new file mode 100644 index 00000000..500e771d --- /dev/null +++ b/advanced_filters/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import model +from . import wizard diff --git a/advanced_filters/__openerp__.py b/advanced_filters/__openerp__.py new file mode 100644 index 00000000..3cd69411 --- /dev/null +++ b/advanced_filters/__openerp__.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + "name": "Advanced filters", + "version": "1.0", + "author": "Therp BV", + "license": "AGPL-3", + "complexity": "normal", + "description": """ +Introduction +------------ + +This addon allows users to apply set operations on filters: Remove or add +certain ids from/to a selection, but also to remove or add another filter's +outcome from/to a filter. This can be stacked, so the filter domain can be +arbitrarily complicated. + +The math is hidden from the user as far as possible, in the hope it's still +user friendly. + +Usage +----- + +After this addon is installed, every list view shows a new menu 'Advanced +filters'. Here the set operations can be applied as necessary. + +Caution +------- + +Deinstalling this module will leave you with filters with empty domains. Use +this query before uninstalling to avoid that: + +``alter table ir_filters rename domain_this to domain`` + """, + "category": "Tools", + "depends": [ + 'base', + 'web', + ], + "data": [ + "wizard/ir_filters_combine_with_existing.xml", + "view/ir_filters.xml", + ], + "js": [ + 'static/src/js/advanced_filters.js', + ], + "css": [ + 'static/src/css/advanced_filters.css', + ], + "qweb": [ + ], + "test": [ + ], + "auto_install": False, + "installable": True, + "application": False, + "external_dependencies": { + 'python': [], + }, +} diff --git a/advanced_filters/model/__init__.py b/advanced_filters/model/__init__.py new file mode 100644 index 00000000..bbae0587 --- /dev/null +++ b/advanced_filters/model/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import ir_filters diff --git a/advanced_filters/model/ir_filters.py b/advanced_filters/model/ir_filters.py new file mode 100644 index 00000000..a709a52a --- /dev/null +++ b/advanced_filters/model/ir_filters.py @@ -0,0 +1,149 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import itertools +from openerp.osv.orm import Model +from openerp.osv import fields, expression +from openerp.tools.safe_eval import const_eval +from openerp.tools.translate import _ + + +class IrFilters(Model): + _inherit = 'ir.filters' + + def _is_frozen_get(self, cr, uid, ids, field_name, args, context=None): + '''determine if this is fixed list of ids''' + result = {} + for this in self.browse(cr, uid, ids, context=context): + domain = const_eval(this.domain) + result[this.id] = (len(domain) == 1 and + expression.is_leaf(domain[0]) and + domain[0][0] == 'id') + return result + + def _domain_get(self, cr, uid, ids, field_name, args, context=None): + '''combine our domain with all domains to union/complement, + this works recursively''' + def eval_n(domain): + '''parse a domain and normalize it''' + return expression.normalize_domain( + const_eval(domain) or [expression.FALSE_LEAF]) + result = {} + for this in self.read( + cr, uid, ids, + ['domain_this', 'union_filter_ids', 'complement_filter_ids'], + context=context): + domain = eval_n(this['domain_this']) + domain = expression.OR( + [domain] + + [eval_n(u['domain']) for u in self.read( + cr, uid, this['union_filter_ids'], ['domain'], + context=context)]) + for c in self.read(cr, uid, this['complement_filter_ids'], + ['domain'], context=context): + domain = expression.AND([ + domain, + ['!'] + eval_n(c['domain'])]) + result[this['id']] = str(domain) + return result + + def _domain_set(self, cr, uid, ids, field_name, field_value, args, + context=None): + self.write(cr, uid, ids, {'domain_this': field_value}) + + _columns = { + 'is_frozen': fields.function( + _is_frozen_get, type='boolean', string='Frozen'), + 'union_filter_ids': fields.many2many( + 'ir.filters', 'ir_filters_union_rel', 'left_filter_id', + 'right_filter_id', 'Add result of filters', + domain=['|', ('active', '=', False), ('active', '=', True)]), + 'complement_filter_ids': fields.many2many( + 'ir.filters', 'ir_filters_complement_rel', 'left_filter_id', + 'right_filter_id', 'Remove result of filters', + domain=['|', ('active', '=', False), ('active', '=', True)]), + 'active': fields.boolean('Active'), + 'domain': fields.function( + _domain_get, type='text', string='Domain', + fnct_inv=_domain_set), + 'domain_this': fields.text( + 'This filter\'s own domain', oldname='domain'), + } + + _defaults = { + 'active': True, + } + + def _evaluate(self, cr, uid, ids, context=None): + assert len(ids) == 1 + this = self.browse(cr, uid, ids[0], context=context) + return self.pool[this.model_id].search( + cr, uid, const_eval(this.domain), context=const_eval(this.context)) + + def button_save(self, cr, uid, ids, context=None): + return {'type': 'ir.actions.act_window.close'} + + def button_freeze(self, cr, uid, ids, context=None): + '''evaluate the filter and write a fixed [('ids', 'in', [])] domain''' + for this in self.browse(cr, uid, ids, context=context): + ids = this._evaluate() + removed_filter_ids = [f.id for f in itertools.chain( + this.union_filter_ids, this.complement_filter_ids)] + this.write({ + 'domain': str([('id', 'in', ids)]), + 'union_filter_ids': [(6, 0, [])], + 'complement_filter_ids': [(6, 0, [])], + }) + #if we removed inactive filters which are orphaned now, delete them + cr.execute('''delete from ir_filters + where + not active and id in %s + and not exists (select right_filter_id + from ir_filters_union_rel where left_filter_id=id) + and not exists (select right_filter_id + from ir_filters_complement_rel where + left_filter_id=id) + ''', + (tuple(removed_filter_ids),)) + + def button_test(self, cr, uid, ids, context=None): + for this in self.browse(cr, uid, ids, context=None): + return { + 'type': 'ir.actions.act_window', + 'name': _('Testing %s') % this.name, + 'res_model': this.model_id, + 'domain': this.domain, + 'view_type': 'form', + 'view_mode': 'tree', + 'context': { + 'default_filter_id': this.id, + }, + } + + def _auto_init(self, cr, context=None): + cr.execute( + 'SELECT count(attname) FROM pg_attribute ' + 'WHERE attrelid = ' + '( SELECT oid FROM pg_class WHERE relname = %s) ' + 'AND attname = %s', (self._table, 'domain_this')) + if not cr.fetchone()[0]: + cr.execute( + 'ALTER table %s RENAME domain TO domain_this' % self._table) + return super(IrFilters, self)._auto_init(cr, context=context) diff --git a/advanced_filters/static/src/css/advanced_filters.css b/advanced_filters/static/src/css/advanced_filters.css new file mode 100644 index 00000000..06a3c8ec --- /dev/null +++ b/advanced_filters/static/src/css/advanced_filters.css @@ -0,0 +1,14 @@ +li.oe_advanced_filters_header +{ + font-weight: bold; +} +.openerp .oe_dropdown_menu > li.oe_advanced_filters_header:hover +{ + background-color: inherit; + background-image: inherit; + box-shadow: none; +} +.openerp .oe_dropdown_menu > li.oe_advanced_filters_header a:hover +{ + cursor: default !important; +} diff --git a/advanced_filters/static/src/img/icon.png b/advanced_filters/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..2937260475c2bf744b31c1d593e3485abbd997d0 GIT binary patch literal 16070 zcmWlgWl&pP5Qc*X2qk!McQ5Wvkrppr+@VNucXx^u_aen1xI4w6SkdC{u3x^H+w)ltPQ0~Oacgi)ADyu4gjNnnvbFVWr*VU#2Z!B z+WW6ZK5GPTjD+2~=#+@3&0Ft$j`Y?gI}H3MXyCBm{J28FJG)*7rf}L+lBwpyR}~&2 zKM18mXcc88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MB2n+%%+_8W1AV&jrtSbTq z2_%V!=1e9!@Gw9UvC}?p0ds{X6yN-8dqA2X0?ko6D99`sbK` z-GLJNLIPqca^MJv+I|7%LqWkn$)B8{(zB8Tc(t>@WB3!FapF+j*wcdH-SBWL4!DgG%r6q^!GVe^p0ofl3QqcmA(B-7_O3wG2v!bmf zwn4HS5`B^ie1Sf-)0PF zFklE@w3w`r+&!Z7++aBJ_EAX$WJ$yRs%DH^(KmUfJU-m8XPS#nII80Dn)@FcK_&pe zKJkl=sPv9M+2KG(BtYCDW6vZo@Maci5a73^jCPRY*jhFOMl!3g!)d$!7yw(k694^6 z{zm8eh%!7}e#0x_c5(0KRsebwoKK&_0?8pwi2?C~M#hgX$l!sacGnunju;yUvZFyZ z1NRf^r1c4X00Br1^gY0qn0jtg=%pL>qIWOo_?!LBqJ6GNbNCzIeq@mo$xk>mq(;3; zMMuHxJ)$5gSs{@p)B9nhBVVLkwto)DK8-zjZr3FJgD| ze6Rbk!5nn4hn~B)bqD|Hu$$^RSr#r{>QQ^5midf$C1rYf5;4c?^Fa1hucPrd@7w!n ze5^?BPli)pjiV0sbdR_$^>dQoqQ1kRoh~x@BpC3yC4AuLCul-hG<*eeTIqPuTW@{X z&9rZ|KL4xLet0Qo!W|{~Ya5%B+vQUeK5ZNQ?P(SnsX?qF`@`q*1(Z). +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +//############################################################################ + +openerp.advanced_filters = function(instance) +{ + var _t = instance.web._t; + + instance.web.Sidebar.include({ + init: function() + { + var result = this._super.apply(this, arguments); + this.sections.push({ + 'name': 'advanced_filters', + 'label': _t('Advanced filters'), + }); + this.items.advanced_filters = []; + return result; + }, + }); + instance.web.ListView.include({ + do_select: function (ids, records) + { + var result = this._super(this, arguments); + if(this.sidebar) + { + this.sidebar.$el.show(); + this.sidebar.$el.children().children().each(function(i, e) + { + $e = jQuery(e) + if($e.find('li.oe_advanced_filters_header').length) + { + $e.find('a[data-index="0"],a[data-index="1"],' + + 'a[data-index="2"],a[data-index="3"]') + .parent().toggle(ids.length); + } + else + { + $e.toggle(ids.length); + } + }); + } + return result; + }, + load_list: function(data) + { + var result = this._super.apply(this, arguments), + self = this; + if(!this.sidebar || this.sidebar.items.advanced_filters.length) + { + return result; + } + this.sidebar.add_items( + 'advanced_filters', + [ + { + label: _t('Marked records'), + classname: 'oe_advanced_filters_header', + }, + { + label: _t('To new selection'), + callback: function () + { + self.advanced_filters_save_selection.apply( + self, arguments); + }, + }, + { + label: _t('To existing selection'), + callback: function (item) + { + self.advanced_filters_combine_with_existing.apply( + self, ['union', 'ids', item]); + }, + }, + { + label: _t('Remove from existing selection'), + callback: function (item) + { + self.advanced_filters_combine_with_existing.apply( + self, ['complement', 'ids', item]); + }, + }, + { + label: _t('Whole result set'), + classname: 'oe_advanced_filters_header', + }, + { + label: _t('To existing selection'), + callback: function (item) + { + self.advanced_filters_combine_with_existing.apply( + self, ['union', 'domain', item]); + }, + }, + { + label: _t('Remove from existing selection'), + callback: function (item) + { + self.advanced_filters_combine_with_existing.apply( + self, ['complement', 'domain', item]); + }, + }, + ] + ); + this.do_select([], []); + return result; + }, + advanced_filters_save_selection: function(item) + { + var self = this; + this.do_action({ + name: item.label, + type: 'ir.actions.act_window', + res_model: 'ir.filters', + views: [[false, 'form']], + target: 'new', + context: { + default_model_id: this.dataset._model.name, + default_domain: JSON.stringify( + [ + ['id', 'in', this.groups.get_selection().ids], + ] + ), + default_context: JSON.stringify({}), + form_view_ref: 'advanced_filters.form_ir_filters_save_new', + }, + }, + { + on_close: function() + { + self.ViewManager.setup_search_view( + self.ViewManager.searchview.view_id, + self.ViewManager.searchview.defaults); + }, + }); + }, + advanced_filters_combine_with_existing: function(action, type, item) + { + var search = this.ViewManager.searchview.build_search_data(), + self = this; + instance.web.pyeval.eval_domains_and_contexts({ + domains: search.domains, + contexts: search.contexts, + group_by_seq: search.groupbys || [] + }).done(function(search) + { + var domain = [], ctx = {}; + switch(type) + { + case 'domain': + domain = search.domain; + ctx = search.context; + _(_.keys(instance.session.user_context)).each( + function (key) {delete ctx[key]}); + break; + case 'ids': + domain = [ + ['id', 'in', self.groups.get_selection().ids], + ] + ctx = {}; + break; + } + self.do_action({ + name: item.label, + type: 'ir.actions.act_window', + res_model: 'ir.filters.combine.with.existing', + views: [[false, 'form']], + target: 'new', + context: _.extend({ + default_model: self.dataset._model.name, + default_domain: JSON.stringify(domain), + default_action: action, + default_context: JSON.stringify(ctx), + }, + self.dataset.context.default_filter_id ? { + default_filter_id: + self.dataset.context.default_filter_id, + } : {}), + }, + { + on_close: function() + { + self.ViewManager.setup_search_view( + self.ViewManager.searchview.view_id, + self.ViewManager.searchview.defaults); + }, + }); + }); + }, + }); +} diff --git a/advanced_filters/view/ir_filters.xml b/advanced_filters/view/ir_filters.xml new file mode 100644 index 00000000..057db6b1 --- /dev/null +++ b/advanced_filters/view/ir_filters.xml @@ -0,0 +1,44 @@ + + + + + ir.filters + + + +
+
+
+ + + + + + + + + + +
+
+ + ir.filters + 999 + +
+ + + + +
+
+
+
+
+
+
diff --git a/advanced_filters/wizard/__init__.py b/advanced_filters/wizard/__init__.py new file mode 100644 index 00000000..608ed687 --- /dev/null +++ b/advanced_filters/wizard/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import ir_filters_combine_with_existing diff --git a/advanced_filters/wizard/ir_filters_combine_with_existing.py b/advanced_filters/wizard/ir_filters_combine_with_existing.py new file mode 100644 index 00000000..0641caf8 --- /dev/null +++ b/advanced_filters/wizard/ir_filters_combine_with_existing.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import time +from openerp.osv.orm import TransientModel +from openerp.osv import fields, expression +from openerp.tools.safe_eval import const_eval + + +class IrFiltersCombineWithExisting(TransientModel): + _name = 'ir.filters.combine.with.existing' + _description = 'Combine a selection with an existing filter' + + _columns = { + 'action': fields.selection( + [('union', 'Union'), ('complement', 'Complement')], + 'Action', required=True), + 'domain': fields.char('Domain', required=True), + 'context': fields.char('Context', required=True), + 'model': fields.char('Model', required=True), + 'filter_id': fields.many2one('ir.filters', 'Filter', required=True), + } + + def button_save(self, cr, uid, ids, context=None): + assert len(ids) == 1 + this = self.browse(cr, uid, ids[0], context=context) + domain = const_eval(this.domain) + is_frozen = (len(domain) == 1 and + expression.is_leaf(domain[0]) and + domain[0][0] == 'id') + + if this.action == 'union': + if is_frozen and this.filter_id.is_frozen: + domain[0][2] = list(set(domain[0][2]).union( + set(const_eval(this.filter_id.domain)[0][2]))) + this.filter_id.write({'domain': str(domain)}) + else: + this.filter_id.write( + { + 'union_filter_ids': [(0, 0, { + 'name': '%s_%s_%d' % ( + this.filter_id.name, 'add', time.time()), + 'active': False, + 'domain': str(domain), + 'context': this.context, + 'model_id': this.model, + 'user_id': uid, + })], + }) + elif this.action == 'complement': + if is_frozen and this.filter_id.is_frozen: + complement_set = set(const_eval(this.filter_id.domain)[0][2]) + domain[0][2] = list( + complement_set.difference(set(domain[0][2]))) + this.filter_id.write({'domain': str(domain)}) + else: + this.filter_id.write( + { + 'complement_filter_ids': [(0, 0, { + 'name': '%s_%s_%d' % ( + this.filter_id.name, 'remove', time.time()), + 'active': False, + 'domain': str(domain), + 'context': this.context, + 'model_id': this.model, + 'user_id': uid, + })], + }) + + return {'type': 'ir.actions.act_window.close'} diff --git a/advanced_filters/wizard/ir_filters_combine_with_existing.xml b/advanced_filters/wizard/ir_filters_combine_with_existing.xml new file mode 100644 index 00000000..bc7028d3 --- /dev/null +++ b/advanced_filters/wizard/ir_filters_combine_with_existing.xml @@ -0,0 +1,21 @@ + + + + + ir.filters.combine.with.existing + +
+ + + + +
+
+
+
+
+
+
From 22cc578a4d2b2969cd4cbab1619f2a67809e8ace Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 28 Jul 2014 10:36:26 +0200 Subject: [PATCH 02/17] [FIX] flake8 --- advanced_filters/model/ir_filters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced_filters/model/ir_filters.py b/advanced_filters/model/ir_filters.py index a709a52a..297afb93 100644 --- a/advanced_filters/model/ir_filters.py +++ b/advanced_filters/model/ir_filters.py @@ -111,7 +111,8 @@ class IrFilters(Model): 'union_filter_ids': [(6, 0, [])], 'complement_filter_ids': [(6, 0, [])], }) - #if we removed inactive filters which are orphaned now, delete them + # if we removed inactive filters which are orphaned now, delete + # them cr.execute('''delete from ir_filters where not active and id in %s From 85b9ce07d40fc8cbf2c554d26c91f54f28d02aad Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 28 Jul 2014 17:30:32 +0200 Subject: [PATCH 03/17] [FIX] use safe_eval instead of const_eval --- advanced_filters/model/ir_filters.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/advanced_filters/model/ir_filters.py b/advanced_filters/model/ir_filters.py index 297afb93..ab4ac9c0 100644 --- a/advanced_filters/model/ir_filters.py +++ b/advanced_filters/model/ir_filters.py @@ -21,7 +21,7 @@ import itertools from openerp.osv.orm import Model from openerp.osv import fields, expression -from openerp.tools.safe_eval import const_eval +from openerp.tools.safe_eval import safe_eval from openerp.tools.translate import _ @@ -32,7 +32,7 @@ class IrFilters(Model): '''determine if this is fixed list of ids''' result = {} for this in self.browse(cr, uid, ids, context=context): - domain = const_eval(this.domain) + domain = safe_eval(this.domain) result[this.id] = (len(domain) == 1 and expression.is_leaf(domain[0]) and domain[0][0] == 'id') @@ -44,7 +44,7 @@ class IrFilters(Model): def eval_n(domain): '''parse a domain and normalize it''' return expression.normalize_domain( - const_eval(domain) or [expression.FALSE_LEAF]) + safe_eval(domain) or [expression.FALSE_LEAF]) result = {} for this in self.read( cr, uid, ids, @@ -95,7 +95,7 @@ class IrFilters(Model): assert len(ids) == 1 this = self.browse(cr, uid, ids[0], context=context) return self.pool[this.model_id].search( - cr, uid, const_eval(this.domain), context=const_eval(this.context)) + cr, uid, safe_eval(this.domain), context=safe_eval(this.context)) def button_save(self, cr, uid, ids, context=None): return {'type': 'ir.actions.act_window.close'} From e39fd7498a13336757a42651c2db7824f81160b6 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 29 Jul 2014 11:44:28 +0200 Subject: [PATCH 04/17] [FIX] call toggle with a boolean --- advanced_filters/static/src/js/advanced_filters.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced_filters/static/src/js/advanced_filters.js b/advanced_filters/static/src/js/advanced_filters.js index 63c59d04..b1725df7 100644 --- a/advanced_filters/static/src/js/advanced_filters.js +++ b/advanced_filters/static/src/js/advanced_filters.js @@ -49,11 +49,11 @@ openerp.advanced_filters = function(instance) { $e.find('a[data-index="0"],a[data-index="1"],' + 'a[data-index="2"],a[data-index="3"]') - .parent().toggle(ids.length); + .parent().toggle(ids.length > 0); } else { - $e.toggle(ids.length); + $e.toggle(ids.length > 0); } }); } From ba0f44979c547dbee2f131f036a741505a32850e Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 29 Jul 2014 12:49:46 +0200 Subject: [PATCH 05/17] [FIX] wording --- advanced_filters/static/src/js/advanced_filters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced_filters/static/src/js/advanced_filters.js b/advanced_filters/static/src/js/advanced_filters.js index b1725df7..5516d704 100644 --- a/advanced_filters/static/src/js/advanced_filters.js +++ b/advanced_filters/static/src/js/advanced_filters.js @@ -99,7 +99,7 @@ openerp.advanced_filters = function(instance) }, }, { - label: _t('Whole result set'), + label: _t('Whole selection'), classname: 'oe_advanced_filters_header', }, { From 3f33663d89993ec0ccbf28bc3d4b01d15456d33a Mon Sep 17 00:00:00 2001 From: OpenERP instance user Date: Thu, 7 Aug 2014 16:55:25 +0200 Subject: [PATCH 06/17] [ADD] advanced filters: translations --- advanced_filters/i18n/advanced_filter.pot | 195 ++++++++++++++++++++++ advanced_filters/i18n/nl.po | 194 +++++++++++++++++++++ 2 files changed, 389 insertions(+) create mode 100644 advanced_filters/i18n/advanced_filter.pot create mode 100644 advanced_filters/i18n/nl.po diff --git a/advanced_filters/i18n/advanced_filter.pot b/advanced_filters/i18n/advanced_filter.pot new file mode 100644 index 00000000..9619a63c --- /dev/null +++ b/advanced_filters/i18n/advanced_filter.pot @@ -0,0 +1,195 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * advanced_filters +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-07-29 10:55+0000\n" +"PO-Revision-Date: 2014-07-29 10:55+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Save filter" +msgstr "" + +#. module: advanced_filters +#: selection:ir.filters.combine.with.existing,action:0 +msgid "Union" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Add the result of following filters" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +#: view:ir.filters.combine.with.existing:0 +msgid "Save" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Freeze filter" +msgstr "" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:94 +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:114 +#, python-format +msgid "Remove from existing selection" +msgstr "" + +#. module: advanced_filters +#: code:addons/advanced_filters/model/ir_filters.py:131 +#, python-format +msgid "Testing %s" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +#: view:ir.filters.combine.with.existing:0 +msgid "or" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters,complement_filter_ids:0 +msgid "Remove result of filters" +msgstr "" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:86 +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:106 +#, python-format +msgid "To existing selection" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters.combine.with.existing:0 +msgid "Combine with existing filter" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Have this filter contain extly the records it currently contains, with no changes in the future. Be careful, you can't undo this operation!" +msgstr "" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:32 +#, python-format +msgid "Advanced filters" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters,active:0 +msgid "Active" +msgstr "" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:74 +#, python-format +msgid "Marked records" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters,is_frozen:0 +msgid "Frozen" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,filter_id:0 +msgid "Filter" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Test filter" +msgstr "" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:78 +#, python-format +msgid "To new selection" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters,domain_this:0 +msgid "This filter's own domain" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Remove the result of following filters" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,context:0 +msgid "Context" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,action:0 +msgid "Action" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,model:0 +msgid "Model" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,domain:0 +msgid "Domain" +msgstr "" + +#. module: advanced_filters +#: field:ir.filters,union_filter_ids:0 +msgid "Add result of filters" +msgstr "" + +#. module: advanced_filters +#: model:ir.model,name:advanced_filters.model_ir_filters_combine_with_existing +msgid "Combine a selection with an existing filter" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Are you sure? You can't undo this operation!" +msgstr "" + +#. module: advanced_filters +#: model:ir.model,name:advanced_filters.model_ir_filters +msgid "Filters" +msgstr "" + +#. module: advanced_filters +#: view:ir.filters:0 +#: view:ir.filters.combine.with.existing:0 +msgid "Cancel" +msgstr "" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:102 +#, python-format +msgid "Whole selection" +msgstr "" + +#. module: advanced_filters +#: selection:ir.filters.combine.with.existing,action:0 +msgid "Complement" +msgstr "" + diff --git a/advanced_filters/i18n/nl.po b/advanced_filters/i18n/nl.po new file mode 100644 index 00000000..817cdf6b --- /dev/null +++ b/advanced_filters/i18n/nl.po @@ -0,0 +1,194 @@ +# This file contains the translation of the following modules: +# * advanced_filters +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-07-29 09:54+0000\n" +"PO-Revision-Date: 2014-07-29 09:54+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Save filter" +msgstr "Opslaan filter" + +#. module: advanced_filters +#: selection:ir.filters.combine.with.existing,action:0 +msgid "Union" +msgstr "Union" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Add the result of following filters" +msgstr "Voeg resultaat to aan de filters" + +#. module: advanced_filters +#: view:ir.filters:0 +#: view:ir.filters.combine.with.existing:0 +msgid "Save" +msgstr "Opslaan" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Freeze filter" +msgstr "Bevries filter" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:94 +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:114 +#, python-format +msgid "Remove from existing selection" +msgstr "Verwijder uit bestaande selectie" + +#. module: advanced_filters +#: code:addons/advanced_filters/model/ir_filters.py:131 +#, python-format +msgid "Testing %s" +msgstr "Testen" + +#. module: advanced_filters +#: view:ir.filters:0 +#: view:ir.filters.combine.with.existing:0 +msgid "or" +msgstr "or" + +#. module: advanced_filters +#: field:ir.filters,complement_filter_ids:0 +msgid "Remove result of filters" +msgstr "Verwijder resultaat van filters" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:86 +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:106 +#, python-format +msgid "To existing selection" +msgstr "Naar bestaande selectie" + +#. module: advanced_filters +#: view:ir.filters.combine.with.existing:0 +msgid "Combine with existing filter" +msgstr "Combineer met bestaande filter" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Have this filter contain exactly the records it currently contains, with no changes in the future. Be careful, you can't undo this operation!" +msgstr "Laat deze filter precies deze records bevatten, zonder veranderingen in de toekomst. Wees voorzichtig, je kan dit niet meer veranderen!" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:32 +#, python-format +msgid "Advanced filters" +msgstr "Geavanceerd filters" + +#. module: advanced_filters +#: field:ir.filters,active:0 +msgid "Active" +msgstr "Actief" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:74 +#, python-format +msgid "Marked records" +msgstr "Gemarkeerde records" + +#. module: advanced_filters +#: field:ir.filters,is_frozen:0 +msgid "Frozen" +msgstr "Bevroren" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,filter_id:0 +msgid "Filter" +msgstr "Filter" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Test filter" +msgstr "Test filter" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:78 +#, python-format +msgid "To new selection" +msgstr "Naar nieuwe selectie" + +#. module: advanced_filters +#: field:ir.filters,domain_this:0 +msgid "This filter's own domain" +msgstr "Deze filters eigen domein" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Remove the result of following filters" +msgstr "Verwijder het resultaat uit de volgende filters" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,context:0 +msgid "Context" +msgstr "Context" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,action:0 +msgid "Action" +msgstr "Actie" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,model:0 +msgid "Model" +msgstr "Model" + +#. module: advanced_filters +#. openerp-web +#: code:addons/advanced_filters/static/src/js/advanced_filters.js:102 +#, python-format +msgid "Whole selection" +msgstr "Hele selectie" + +#. module: advanced_filters +#: field:ir.filters.combine.with.existing,domain:0 +msgid "Domain" +msgstr "Domein" + +#. module: advanced_filters +#: field:ir.filters,union_filter_ids:0 +msgid "Add result of filters" +msgstr "Voeg resultaat toe aan filters" + +#. module: advanced_filters +#: model:ir.model,name:advanced_filters.model_ir_filters_combine_with_existing +msgid "Combine a selection with an existing filter" +msgstr "Combineer een selectie met een bestaande filter" + +#. module: advanced_filters +#: view:ir.filters:0 +msgid "Are you sure? You can't undo this operation!" +msgstr "Weet u het zeker? U kan deze operatie niet meer ongedaan maken" + +#. module: advanced_filters +#: model:ir.model,name:advanced_filters.model_ir_filters +msgid "Filters" +msgstr "Filters" + +#. module: advanced_filters +#: view:ir.filters:0 +#: view:ir.filters.combine.with.existing:0 +msgid "Cancel" +msgstr "Annuleren" + +#. module: advanced_filters +#: selection:ir.filters.combine.with.existing,action:0 +msgid "Complement" +msgstr "Aanvullen" + From 354d17927fb3bd5fdda01375869d47250830010c Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 25 Aug 2014 10:39:28 +0200 Subject: [PATCH 07/17] [IMP] better wording [IMP] reorder filters --- advanced_filters/i18n/nl.po | 24 ++++++------- .../static/src/js/advanced_filters.js | 36 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/advanced_filters/i18n/nl.po b/advanced_filters/i18n/nl.po index 817cdf6b..3c44657e 100644 --- a/advanced_filters/i18n/nl.po +++ b/advanced_filters/i18n/nl.po @@ -27,7 +27,7 @@ msgstr "Union" #. module: advanced_filters #: view:ir.filters:0 msgid "Add the result of following filters" -msgstr "Voeg resultaat to aan de filters" +msgstr "Voeg resultaat van onderstaande filteringen toe aan filter" #. module: advanced_filters #: view:ir.filters:0 @@ -45,8 +45,8 @@ msgstr "Bevries filter" #: code:addons/advanced_filters/static/src/js/advanced_filters.js:94 #: code:addons/advanced_filters/static/src/js/advanced_filters.js:114 #, python-format -msgid "Remove from existing selection" -msgstr "Verwijder uit bestaande selectie" +msgid "Remove from existing filter" +msgstr "Verwijder uit bestaand filter" #. module: advanced_filters #: code:addons/advanced_filters/model/ir_filters.py:131 @@ -70,8 +70,8 @@ msgstr "Verwijder resultaat van filters" #: code:addons/advanced_filters/static/src/js/advanced_filters.js:86 #: code:addons/advanced_filters/static/src/js/advanced_filters.js:106 #, python-format -msgid "To existing selection" -msgstr "Naar bestaande selectie" +msgid "To existing filter" +msgstr "Voeg toe aan bestaand filter" #. module: advanced_filters #: view:ir.filters.combine.with.existing:0 @@ -88,7 +88,7 @@ msgstr "Laat deze filter precies deze records bevatten, zonder veranderingen in #: code:addons/advanced_filters/static/src/js/advanced_filters.js:32 #, python-format msgid "Advanced filters" -msgstr "Geavanceerd filters" +msgstr "Geavanceerde filters" #. module: advanced_filters #: field:ir.filters,active:0 @@ -100,7 +100,7 @@ msgstr "Actief" #: code:addons/advanced_filters/static/src/js/advanced_filters.js:74 #, python-format msgid "Marked records" -msgstr "Gemarkeerde records" +msgstr "Aangevinkte records (verzameling)" #. module: advanced_filters #: field:ir.filters,is_frozen:0 @@ -121,8 +121,8 @@ msgstr "Test filter" #. openerp-web #: code:addons/advanced_filters/static/src/js/advanced_filters.js:78 #, python-format -msgid "To new selection" -msgstr "Naar nieuwe selectie" +msgid "To new filter" +msgstr "Opslaan als nieuw filter" #. module: advanced_filters #: field:ir.filters,domain_this:0 @@ -132,7 +132,7 @@ msgstr "Deze filters eigen domein" #. module: advanced_filters #: view:ir.filters:0 msgid "Remove the result of following filters" -msgstr "Verwijder het resultaat uit de volgende filters" +msgstr "Verwijder resultaat van onderstaande filteringen uit filter" #. module: advanced_filters #: field:ir.filters.combine.with.existing,context:0 @@ -153,8 +153,8 @@ msgstr "Model" #. openerp-web #: code:addons/advanced_filters/static/src/js/advanced_filters.js:102 #, python-format -msgid "Whole selection" -msgstr "Hele selectie" +msgid "Whole selection (criteria)" +msgstr "Alle records (als criteria)" #. module: advanced_filters #: field:ir.filters.combine.with.existing,domain:0 diff --git a/advanced_filters/static/src/js/advanced_filters.js b/advanced_filters/static/src/js/advanced_filters.js index 5516d704..df90e2cb 100644 --- a/advanced_filters/static/src/js/advanced_filters.js +++ b/advanced_filters/static/src/js/advanced_filters.js @@ -71,51 +71,51 @@ openerp.advanced_filters = function(instance) 'advanced_filters', [ { - label: _t('Marked records'), + label: _t('Whole selection (criteria)'), classname: 'oe_advanced_filters_header', }, { - label: _t('To new selection'), - callback: function () - { - self.advanced_filters_save_selection.apply( - self, arguments); - }, - }, - { - label: _t('To existing selection'), + label: _t('To existing filter'), callback: function (item) { self.advanced_filters_combine_with_existing.apply( - self, ['union', 'ids', item]); + self, ['union', 'domain', item]); }, }, { - label: _t('Remove from existing selection'), + label: _t('Remove from existing filter'), callback: function (item) { self.advanced_filters_combine_with_existing.apply( - self, ['complement', 'ids', item]); + self, ['complement', 'domain', item]); }, }, { - label: _t('Whole selection'), + label: _t('Marked records'), classname: 'oe_advanced_filters_header', }, { - label: _t('To existing selection'), + label: _t('To new filter'), + callback: function () + { + self.advanced_filters_save_selection.apply( + self, arguments); + }, + }, + { + label: _t('To existing filter'), callback: function (item) { self.advanced_filters_combine_with_existing.apply( - self, ['union', 'domain', item]); + self, ['union', 'ids', item]); }, }, { - label: _t('Remove from existing selection'), + label: _t('Remove from existing filter'), callback: function (item) { self.advanced_filters_combine_with_existing.apply( - self, ['complement', 'domain', item]); + self, ['complement', 'ids', item]); }, }, ] From 247b7de11bf2166f531839336fd17de1cb32f2bb Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 25 Aug 2014 10:42:22 +0200 Subject: [PATCH 08/17] [FIX] translated string --- advanced_filters/i18n/nl.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced_filters/i18n/nl.po b/advanced_filters/i18n/nl.po index 3c44657e..8f7c43f0 100644 --- a/advanced_filters/i18n/nl.po +++ b/advanced_filters/i18n/nl.po @@ -52,7 +52,7 @@ msgstr "Verwijder uit bestaand filter" #: code:addons/advanced_filters/model/ir_filters.py:131 #, python-format msgid "Testing %s" -msgstr "Testen" +msgstr "Testen %s" #. module: advanced_filters #: view:ir.filters:0 From 72ab78a850fe2d1c11ccdcf6a8326957c59eaf6a Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 25 Aug 2014 10:42:49 +0200 Subject: [PATCH 09/17] [FIX] typo in comment, pass context --- advanced_filters/model/ir_filters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced_filters/model/ir_filters.py b/advanced_filters/model/ir_filters.py index ab4ac9c0..957880e8 100644 --- a/advanced_filters/model/ir_filters.py +++ b/advanced_filters/model/ir_filters.py @@ -101,7 +101,7 @@ class IrFilters(Model): return {'type': 'ir.actions.act_window.close'} def button_freeze(self, cr, uid, ids, context=None): - '''evaluate the filter and write a fixed [('ids', 'in', [])] domain''' + '''evaluate the filter and write a fixed [('id', 'in', [])] domain''' for this in self.browse(cr, uid, ids, context=context): ids = this._evaluate() removed_filter_ids = [f.id for f in itertools.chain( @@ -125,7 +125,7 @@ class IrFilters(Model): (tuple(removed_filter_ids),)) def button_test(self, cr, uid, ids, context=None): - for this in self.browse(cr, uid, ids, context=None): + for this in self.browse(cr, uid, ids, context=context): return { 'type': 'ir.actions.act_window', 'name': _('Testing %s') % this.name, From 8afd947a9496d7ea9328e3f4b3f8bddec4636374 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 25 Aug 2014 10:58:22 +0200 Subject: [PATCH 10/17] [FIX] show correct menu items after reordering --- advanced_filters/static/src/js/advanced_filters.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced_filters/static/src/js/advanced_filters.js b/advanced_filters/static/src/js/advanced_filters.js index df90e2cb..1c6d497a 100644 --- a/advanced_filters/static/src/js/advanced_filters.js +++ b/advanced_filters/static/src/js/advanced_filters.js @@ -47,8 +47,8 @@ openerp.advanced_filters = function(instance) $e = jQuery(e) if($e.find('li.oe_advanced_filters_header').length) { - $e.find('a[data-index="0"],a[data-index="1"],' + - 'a[data-index="2"],a[data-index="3"]') + $e.find('a[data-index="3"],a[data-index="4"],' + + 'a[data-index="5"],a[data-index="6"]') .parent().toggle(ids.length > 0); } else From 6ff2b14f154b0a6601dbe2ee754007ceabd64965 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 25 Aug 2014 11:01:47 +0200 Subject: [PATCH 11/17] [FIX] advanced filters not visible when switching views --- .../static/src/js/advanced_filters.js | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/advanced_filters/static/src/js/advanced_filters.js b/advanced_filters/static/src/js/advanced_filters.js index 1c6d497a..cfea223b 100644 --- a/advanced_filters/static/src/js/advanced_filters.js +++ b/advanced_filters/static/src/js/advanced_filters.js @@ -39,24 +39,7 @@ openerp.advanced_filters = function(instance) do_select: function (ids, records) { var result = this._super(this, arguments); - if(this.sidebar) - { - this.sidebar.$el.show(); - this.sidebar.$el.children().children().each(function(i, e) - { - $e = jQuery(e) - if($e.find('li.oe_advanced_filters_header').length) - { - $e.find('a[data-index="3"],a[data-index="4"],' + - 'a[data-index="5"],a[data-index="6"]') - .parent().toggle(ids.length > 0); - } - else - { - $e.toggle(ids.length > 0); - } - }); - } + this.advanced_filters_show(ids); return result; }, load_list: function(data) @@ -65,6 +48,7 @@ openerp.advanced_filters = function(instance) self = this; if(!this.sidebar || this.sidebar.items.advanced_filters.length) { + this.advanced_filters_show([]); return result; } this.sidebar.add_items( @@ -123,6 +107,27 @@ openerp.advanced_filters = function(instance) this.do_select([], []); return result; }, + advanced_filters_show: function(ids) + { + if(this.sidebar) + { + this.sidebar.$el.show(); + this.sidebar.$el.children().children().each(function(i, e) + { + $e = jQuery(e) + if($e.find('li.oe_advanced_filters_header').length) + { + $e.find('a[data-index="3"],a[data-index="4"],' + + 'a[data-index="5"],a[data-index="6"]') + .parent().toggle(ids.length > 0); + } + else + { + $e.toggle(ids.length > 0); + } + }); + } + }, advanced_filters_save_selection: function(item) { var self = this; From 48e9c42a1c91369757438628d14a730fefe0b313 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 24 Nov 2014 14:26:40 +0100 Subject: [PATCH 12/17] [REN] rename to web_advanced_filters --- .../__init__.py | 0 .../__openerp__.py | 1 + web_advanced_filters/data/migration.xml | 6 ++++++ .../i18n/advanced_filter.pot | 0 .../i18n/nl.po | 0 .../model/__init__.py | 0 .../model/ir_filters.py | 17 +++++++++++++++++ .../static/src/css/advanced_filters.css | 0 .../static/src/img/icon.png | Bin .../static/src/js/advanced_filters.js | 0 .../view/ir_filters.xml | 0 .../wizard/__init__.py | 0 .../wizard/ir_filters_combine_with_existing.py | 0 .../ir_filters_combine_with_existing.xml | 0 14 files changed, 24 insertions(+) rename {advanced_filters => web_advanced_filters}/__init__.py (100%) rename {advanced_filters => web_advanced_filters}/__openerp__.py (98%) create mode 100644 web_advanced_filters/data/migration.xml rename {advanced_filters => web_advanced_filters}/i18n/advanced_filter.pot (100%) rename {advanced_filters => web_advanced_filters}/i18n/nl.po (100%) rename {advanced_filters => web_advanced_filters}/model/__init__.py (100%) rename {advanced_filters => web_advanced_filters}/model/ir_filters.py (90%) rename {advanced_filters => web_advanced_filters}/static/src/css/advanced_filters.css (100%) rename {advanced_filters => web_advanced_filters}/static/src/img/icon.png (100%) rename {advanced_filters => web_advanced_filters}/static/src/js/advanced_filters.js (100%) rename {advanced_filters => web_advanced_filters}/view/ir_filters.xml (100%) rename {advanced_filters => web_advanced_filters}/wizard/__init__.py (100%) rename {advanced_filters => web_advanced_filters}/wizard/ir_filters_combine_with_existing.py (100%) rename {advanced_filters => web_advanced_filters}/wizard/ir_filters_combine_with_existing.xml (100%) diff --git a/advanced_filters/__init__.py b/web_advanced_filters/__init__.py similarity index 100% rename from advanced_filters/__init__.py rename to web_advanced_filters/__init__.py diff --git a/advanced_filters/__openerp__.py b/web_advanced_filters/__openerp__.py similarity index 98% rename from advanced_filters/__openerp__.py rename to web_advanced_filters/__openerp__.py index 3cd69411..4cd39dfb 100644 --- a/advanced_filters/__openerp__.py +++ b/web_advanced_filters/__openerp__.py @@ -56,6 +56,7 @@ this query before uninstalling to avoid that: 'web', ], "data": [ + "data/migration.xml", "wizard/ir_filters_combine_with_existing.xml", "view/ir_filters.xml", ], diff --git a/web_advanced_filters/data/migration.xml b/web_advanced_filters/data/migration.xml new file mode 100644 index 00000000..0219058d --- /dev/null +++ b/web_advanced_filters/data/migration.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/advanced_filters/i18n/advanced_filter.pot b/web_advanced_filters/i18n/advanced_filter.pot similarity index 100% rename from advanced_filters/i18n/advanced_filter.pot rename to web_advanced_filters/i18n/advanced_filter.pot diff --git a/advanced_filters/i18n/nl.po b/web_advanced_filters/i18n/nl.po similarity index 100% rename from advanced_filters/i18n/nl.po rename to web_advanced_filters/i18n/nl.po diff --git a/advanced_filters/model/__init__.py b/web_advanced_filters/model/__init__.py similarity index 100% rename from advanced_filters/model/__init__.py rename to web_advanced_filters/model/__init__.py diff --git a/advanced_filters/model/ir_filters.py b/web_advanced_filters/model/ir_filters.py similarity index 90% rename from advanced_filters/model/ir_filters.py rename to web_advanced_filters/model/ir_filters.py index 957880e8..07b437a4 100644 --- a/advanced_filters/model/ir_filters.py +++ b/web_advanced_filters/model/ir_filters.py @@ -148,3 +148,20 @@ class IrFilters(Model): cr.execute( 'ALTER table %s RENAME domain TO domain_this' % self._table) return super(IrFilters, self)._auto_init(cr, context=context) + + def _migrate_name_change(self, cr, uid, context=None): + cr.execute( + "select id from ir_module_module where name='advanced_filters' " + "and author='Therp BV'") + old_name_installed = cr.fetchall() + if not old_name_installed: + return + cr.execute( + "delete from ir_model_data where module='web_advanced_filters'") + cr.execute( + "update ir_model_data set module='web_advanced_filters' " + "where module='advanced_filters'") + cr.execute( + "update ir_module_module set state='to remove' where " + "name='advanced_filters' and state not in " + "('uninstalled', 'to remove')") diff --git a/advanced_filters/static/src/css/advanced_filters.css b/web_advanced_filters/static/src/css/advanced_filters.css similarity index 100% rename from advanced_filters/static/src/css/advanced_filters.css rename to web_advanced_filters/static/src/css/advanced_filters.css diff --git a/advanced_filters/static/src/img/icon.png b/web_advanced_filters/static/src/img/icon.png similarity index 100% rename from advanced_filters/static/src/img/icon.png rename to web_advanced_filters/static/src/img/icon.png diff --git a/advanced_filters/static/src/js/advanced_filters.js b/web_advanced_filters/static/src/js/advanced_filters.js similarity index 100% rename from advanced_filters/static/src/js/advanced_filters.js rename to web_advanced_filters/static/src/js/advanced_filters.js diff --git a/advanced_filters/view/ir_filters.xml b/web_advanced_filters/view/ir_filters.xml similarity index 100% rename from advanced_filters/view/ir_filters.xml rename to web_advanced_filters/view/ir_filters.xml diff --git a/advanced_filters/wizard/__init__.py b/web_advanced_filters/wizard/__init__.py similarity index 100% rename from advanced_filters/wizard/__init__.py rename to web_advanced_filters/wizard/__init__.py diff --git a/advanced_filters/wizard/ir_filters_combine_with_existing.py b/web_advanced_filters/wizard/ir_filters_combine_with_existing.py similarity index 100% rename from advanced_filters/wizard/ir_filters_combine_with_existing.py rename to web_advanced_filters/wizard/ir_filters_combine_with_existing.py diff --git a/advanced_filters/wizard/ir_filters_combine_with_existing.xml b/web_advanced_filters/wizard/ir_filters_combine_with_existing.xml similarity index 100% rename from advanced_filters/wizard/ir_filters_combine_with_existing.xml rename to web_advanced_filters/wizard/ir_filters_combine_with_existing.xml From b0892b2b3b5a10be1b6690432fd8f8fc1230f0e5 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 24 Nov 2014 15:19:52 +0100 Subject: [PATCH 13/17] [FIX] do the renaming properly --- web_advanced_filters/__openerp__.py | 4 +- web_advanced_filters/i18n/advanced_filter.pot | 88 +++++++++---------- web_advanced_filters/i18n/nl.po | 88 +++++++++---------- ...d_filters.css => web_advanced_filters.css} | 0 ...ced_filters.js => web_advanced_filters.js} | 4 +- 5 files changed, 92 insertions(+), 92 deletions(-) rename web_advanced_filters/static/src/css/{advanced_filters.css => web_advanced_filters.css} (100%) rename web_advanced_filters/static/src/js/{advanced_filters.js => web_advanced_filters.js} (98%) diff --git a/web_advanced_filters/__openerp__.py b/web_advanced_filters/__openerp__.py index 4cd39dfb..b91430b5 100644 --- a/web_advanced_filters/__openerp__.py +++ b/web_advanced_filters/__openerp__.py @@ -61,10 +61,10 @@ this query before uninstalling to avoid that: "view/ir_filters.xml", ], "js": [ - 'static/src/js/advanced_filters.js', + 'static/src/js/web_advanced_filters.js', ], "css": [ - 'static/src/css/advanced_filters.css', + 'static/src/css/web_advanced_filters.css', ], "qweb": [ ], diff --git a/web_advanced_filters/i18n/advanced_filter.pot b/web_advanced_filters/i18n/advanced_filter.pot index 9619a63c..5691d68c 100644 --- a/web_advanced_filters/i18n/advanced_filter.pot +++ b/web_advanced_filters/i18n/advanced_filter.pot @@ -1,6 +1,6 @@ # Translation of OpenERP Server. # This file contains the translation of the following modules: -# * advanced_filters +# * web_advanced_filters # msgid "" msgstr "" @@ -15,180 +15,180 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Save filter" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: selection:ir.filters.combine.with.existing,action:0 msgid "Union" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Add the result of following filters" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 #: view:ir.filters.combine.with.existing:0 msgid "Save" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Freeze filter" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:94 -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:114 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:94 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:114 #, python-format msgid "Remove from existing selection" msgstr "" -#. module: advanced_filters -#: code:addons/advanced_filters/model/ir_filters.py:131 +#. module: web_advanced_filters +#: code:addons/web_advanced_filters/model/ir_filters.py:131 #, python-format msgid "Testing %s" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 #: view:ir.filters.combine.with.existing:0 msgid "or" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,complement_filter_ids:0 msgid "Remove result of filters" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:86 -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:106 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:86 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:106 #, python-format msgid "To existing selection" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters.combine.with.existing:0 msgid "Combine with existing filter" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Have this filter contain extly the records it currently contains, with no changes in the future. Be careful, you can't undo this operation!" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:32 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:32 #, python-format msgid "Advanced filters" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,active:0 msgid "Active" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:74 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:74 #, python-format msgid "Marked records" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,is_frozen:0 msgid "Frozen" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,filter_id:0 msgid "Filter" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Test filter" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:78 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:78 #, python-format msgid "To new selection" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,domain_this:0 msgid "This filter's own domain" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Remove the result of following filters" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,context:0 msgid "Context" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,action:0 msgid "Action" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,model:0 msgid "Model" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,domain:0 msgid "Domain" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,union_filter_ids:0 msgid "Add result of filters" msgstr "" -#. module: advanced_filters -#: model:ir.model,name:advanced_filters.model_ir_filters_combine_with_existing +#. module: web_advanced_filters +#: model:ir.model,name:web_advanced_filters.model_ir_filters_combine_with_existing msgid "Combine a selection with an existing filter" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Are you sure? You can't undo this operation!" msgstr "" -#. module: advanced_filters -#: model:ir.model,name:advanced_filters.model_ir_filters +#. module: web_advanced_filters +#: model:ir.model,name:web_advanced_filters.model_ir_filters msgid "Filters" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 #: view:ir.filters.combine.with.existing:0 msgid "Cancel" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:102 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:102 #, python-format msgid "Whole selection" msgstr "" -#. module: advanced_filters +#. module: web_advanced_filters #: selection:ir.filters.combine.with.existing,action:0 msgid "Complement" msgstr "" diff --git a/web_advanced_filters/i18n/nl.po b/web_advanced_filters/i18n/nl.po index 8f7c43f0..45026482 100644 --- a/web_advanced_filters/i18n/nl.po +++ b/web_advanced_filters/i18n/nl.po @@ -1,5 +1,5 @@ # This file contains the translation of the following modules: -# * advanced_filters +# * web_advanced_filters # msgid "" msgstr "" @@ -14,180 +14,180 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Save filter" msgstr "Opslaan filter" -#. module: advanced_filters +#. module: web_advanced_filters #: selection:ir.filters.combine.with.existing,action:0 msgid "Union" msgstr "Union" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Add the result of following filters" msgstr "Voeg resultaat van onderstaande filteringen toe aan filter" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 #: view:ir.filters.combine.with.existing:0 msgid "Save" msgstr "Opslaan" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Freeze filter" msgstr "Bevries filter" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:94 -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:114 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:94 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:114 #, python-format msgid "Remove from existing filter" msgstr "Verwijder uit bestaand filter" -#. module: advanced_filters -#: code:addons/advanced_filters/model/ir_filters.py:131 +#. module: web_advanced_filters +#: code:addons/web_advanced_filters/model/ir_filters.py:131 #, python-format msgid "Testing %s" msgstr "Testen %s" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 #: view:ir.filters.combine.with.existing:0 msgid "or" msgstr "or" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,complement_filter_ids:0 msgid "Remove result of filters" msgstr "Verwijder resultaat van filters" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:86 -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:106 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:86 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:106 #, python-format msgid "To existing filter" msgstr "Voeg toe aan bestaand filter" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters.combine.with.existing:0 msgid "Combine with existing filter" msgstr "Combineer met bestaande filter" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Have this filter contain exactly the records it currently contains, with no changes in the future. Be careful, you can't undo this operation!" msgstr "Laat deze filter precies deze records bevatten, zonder veranderingen in de toekomst. Wees voorzichtig, je kan dit niet meer veranderen!" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:32 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:32 #, python-format msgid "Advanced filters" msgstr "Geavanceerde filters" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,active:0 msgid "Active" msgstr "Actief" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:74 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:74 #, python-format msgid "Marked records" msgstr "Aangevinkte records (verzameling)" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,is_frozen:0 msgid "Frozen" msgstr "Bevroren" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,filter_id:0 msgid "Filter" msgstr "Filter" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Test filter" msgstr "Test filter" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:78 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:78 #, python-format msgid "To new filter" msgstr "Opslaan als nieuw filter" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,domain_this:0 msgid "This filter's own domain" msgstr "Deze filters eigen domein" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Remove the result of following filters" msgstr "Verwijder resultaat van onderstaande filteringen uit filter" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,context:0 msgid "Context" msgstr "Context" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,action:0 msgid "Action" msgstr "Actie" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,model:0 msgid "Model" msgstr "Model" -#. module: advanced_filters +#. module: web_advanced_filters #. openerp-web -#: code:addons/advanced_filters/static/src/js/advanced_filters.js:102 +#: code:addons/web_advanced_filters/static/src/js/web_advanced_filters.js:102 #, python-format msgid "Whole selection (criteria)" msgstr "Alle records (als criteria)" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters.combine.with.existing,domain:0 msgid "Domain" msgstr "Domein" -#. module: advanced_filters +#. module: web_advanced_filters #: field:ir.filters,union_filter_ids:0 msgid "Add result of filters" msgstr "Voeg resultaat toe aan filters" -#. module: advanced_filters -#: model:ir.model,name:advanced_filters.model_ir_filters_combine_with_existing +#. module: web_advanced_filters +#: model:ir.model,name:web_advanced_filters.model_ir_filters_combine_with_existing msgid "Combine a selection with an existing filter" msgstr "Combineer een selectie met een bestaande filter" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 msgid "Are you sure? You can't undo this operation!" msgstr "Weet u het zeker? U kan deze operatie niet meer ongedaan maken" -#. module: advanced_filters -#: model:ir.model,name:advanced_filters.model_ir_filters +#. module: web_advanced_filters +#: model:ir.model,name:web_advanced_filters.model_ir_filters msgid "Filters" msgstr "Filters" -#. module: advanced_filters +#. module: web_advanced_filters #: view:ir.filters:0 #: view:ir.filters.combine.with.existing:0 msgid "Cancel" msgstr "Annuleren" -#. module: advanced_filters +#. module: web_advanced_filters #: selection:ir.filters.combine.with.existing,action:0 msgid "Complement" msgstr "Aanvullen" diff --git a/web_advanced_filters/static/src/css/advanced_filters.css b/web_advanced_filters/static/src/css/web_advanced_filters.css similarity index 100% rename from web_advanced_filters/static/src/css/advanced_filters.css rename to web_advanced_filters/static/src/css/web_advanced_filters.css diff --git a/web_advanced_filters/static/src/js/advanced_filters.js b/web_advanced_filters/static/src/js/web_advanced_filters.js similarity index 98% rename from web_advanced_filters/static/src/js/advanced_filters.js rename to web_advanced_filters/static/src/js/web_advanced_filters.js index cfea223b..9a194889 100644 --- a/web_advanced_filters/static/src/js/advanced_filters.js +++ b/web_advanced_filters/static/src/js/web_advanced_filters.js @@ -19,7 +19,7 @@ // //############################################################################ -openerp.advanced_filters = function(instance) +openerp.web_advanced_filters = function(instance) { var _t = instance.web._t; @@ -145,7 +145,7 @@ openerp.advanced_filters = function(instance) ] ), default_context: JSON.stringify({}), - form_view_ref: 'advanced_filters.form_ir_filters_save_new', + form_view_ref: 'web_advanced_filters.form_ir_filters_save_new', }, }, { From a912bb470f0bb1aa60bdddd0f20f04616deb1ee3 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 24 Nov 2014 15:34:57 +0100 Subject: [PATCH 14/17] [ADD] duplicate saving new filters to menu (usability) --- .../static/src/js/web_advanced_filters.js | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/web_advanced_filters/static/src/js/web_advanced_filters.js b/web_advanced_filters/static/src/js/web_advanced_filters.js index 9a194889..1c3dd505 100644 --- a/web_advanced_filters/static/src/js/web_advanced_filters.js +++ b/web_advanced_filters/static/src/js/web_advanced_filters.js @@ -58,6 +58,14 @@ openerp.web_advanced_filters = function(instance) label: _t('Whole selection (criteria)'), classname: 'oe_advanced_filters_header', }, + { + label: _t('To new filter'), + callback: function () + { + self.advanced_filters_save_criteria.apply( + self, arguments); + }, + }, { label: _t('To existing filter'), callback: function (item) @@ -117,8 +125,8 @@ openerp.web_advanced_filters = function(instance) $e = jQuery(e) if($e.find('li.oe_advanced_filters_header').length) { - $e.find('a[data-index="3"],a[data-index="4"],' + - 'a[data-index="5"],a[data-index="6"]') + $e.find('a[data-index="4"],a[data-index="5"],' + + 'a[data-index="6"],a[data-index="7"]') .parent().toggle(ids.length > 0); } else @@ -128,6 +136,42 @@ openerp.web_advanced_filters = function(instance) }); } }, + advanced_filters_save_criteria: function(item) + { + var search = this.ViewManager.searchview.build_search_data(), + self = this; + instance.web.pyeval.eval_domains_and_contexts({ + domains: search.domains, + contexts: search.contexts, + group_by_seq: search.groupbys || [] + }).done(function(search) + { + var ctx = search.context; + _(_.keys(instance.session.user_context)).each( + function (key) {delete ctx[key]}); + self.do_action({ + name: item.label, + type: 'ir.actions.act_window', + res_model: 'ir.filters', + views: [[false, 'form']], + target: 'new', + context: { + default_model_id: self.dataset._model.name, + default_domain: JSON.stringify(search.domain), + default_context: JSON.stringify(ctx), + form_view_ref: 'web_advanced_filters.form_ir_filters_save_new', + }, + }, + { + on_close: function() + { + self.ViewManager.setup_search_view( + self.ViewManager.searchview.view_id, + self.ViewManager.searchview.defaults); + }, + }); + }); + }, advanced_filters_save_selection: function(item) { var self = this; From fcd77d206cd248e3c0e4735ad36b4af8acc32fbb Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 24 Nov 2014 15:53:02 +0100 Subject: [PATCH 15/17] [FIX] use safe_eval to account for names like False --- .../wizard/ir_filters_combine_with_existing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web_advanced_filters/wizard/ir_filters_combine_with_existing.py b/web_advanced_filters/wizard/ir_filters_combine_with_existing.py index 0641caf8..7cb48206 100644 --- a/web_advanced_filters/wizard/ir_filters_combine_with_existing.py +++ b/web_advanced_filters/wizard/ir_filters_combine_with_existing.py @@ -21,7 +21,7 @@ import time from openerp.osv.orm import TransientModel from openerp.osv import fields, expression -from openerp.tools.safe_eval import const_eval +from openerp.tools.safe_eval import safe_eval class IrFiltersCombineWithExisting(TransientModel): @@ -41,7 +41,7 @@ class IrFiltersCombineWithExisting(TransientModel): def button_save(self, cr, uid, ids, context=None): assert len(ids) == 1 this = self.browse(cr, uid, ids[0], context=context) - domain = const_eval(this.domain) + domain = safe_eval(this.domain) is_frozen = (len(domain) == 1 and expression.is_leaf(domain[0]) and domain[0][0] == 'id') @@ -49,7 +49,7 @@ class IrFiltersCombineWithExisting(TransientModel): if this.action == 'union': if is_frozen and this.filter_id.is_frozen: domain[0][2] = list(set(domain[0][2]).union( - set(const_eval(this.filter_id.domain)[0][2]))) + set(safe_eval(this.filter_id.domain)[0][2]))) this.filter_id.write({'domain': str(domain)}) else: this.filter_id.write( @@ -66,7 +66,7 @@ class IrFiltersCombineWithExisting(TransientModel): }) elif this.action == 'complement': if is_frozen and this.filter_id.is_frozen: - complement_set = set(const_eval(this.filter_id.domain)[0][2]) + complement_set = set(safe_eval(this.filter_id.domain)[0][2]) domain[0][2] = list( complement_set.difference(set(domain[0][2]))) this.filter_id.write({'domain': str(domain)}) From 94a7f48d06059609a3d07e5774f0467b6bb576af Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 24 Nov 2014 16:04:27 +0100 Subject: [PATCH 16/17] [FIX] cope with faulty expressions in filters --- web_advanced_filters/model/ir_filters.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web_advanced_filters/model/ir_filters.py b/web_advanced_filters/model/ir_filters.py index 07b437a4..fb09d45b 100644 --- a/web_advanced_filters/model/ir_filters.py +++ b/web_advanced_filters/model/ir_filters.py @@ -32,7 +32,10 @@ class IrFilters(Model): '''determine if this is fixed list of ids''' result = {} for this in self.browse(cr, uid, ids, context=context): - domain = safe_eval(this.domain) + try: + domain = safe_eval(this.domain) + except: + domain = [expression.FALSE_LEAF] result[this.id] = (len(domain) == 1 and expression.is_leaf(domain[0]) and domain[0][0] == 'id') @@ -43,8 +46,13 @@ class IrFilters(Model): this works recursively''' def eval_n(domain): '''parse a domain and normalize it''' + try: + domain = safe_eval(domain) + except: + domain = [expression.FALSE_LEAF] return expression.normalize_domain( - safe_eval(domain) or [expression.FALSE_LEAF]) + domain or [expression.FALSE_LEAF]) + result = {} for this in self.read( cr, uid, ids, From 52555c3edbd82866c91b78df3617283b54560ed8 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 24 Nov 2014 16:05:01 +0100 Subject: [PATCH 17/17] [ADD] hide advanced filter menu if there is no filter and nothing checked --- .../static/src/js/web_advanced_filters.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web_advanced_filters/static/src/js/web_advanced_filters.js b/web_advanced_filters/static/src/js/web_advanced_filters.js index 1c3dd505..ae1a8ea1 100644 --- a/web_advanced_filters/static/src/js/web_advanced_filters.js +++ b/web_advanced_filters/static/src/js/web_advanced_filters.js @@ -117,6 +117,7 @@ openerp.web_advanced_filters = function(instance) }, advanced_filters_show: function(ids) { + var self = this; if(this.sidebar) { this.sidebar.$el.show(); @@ -125,9 +126,20 @@ openerp.web_advanced_filters = function(instance) $e = jQuery(e) if($e.find('li.oe_advanced_filters_header').length) { + var search = self.ViewManager.searchview + .build_search_data(); + $e.find('a[data-index="0"],a[data-index="1"],' + + 'a[data-index="2"],a[data-index="3"]') + .parent().toggle( + search.contexts.length > 0 || + search.domains.length > 0); $e.find('a[data-index="4"],a[data-index="5"],' + 'a[data-index="6"],a[data-index="7"]') .parent().toggle(ids.length > 0); + $e.toggle( + search.contexts.length > 0 || + search.domains.length > 0 || + ids.length > 0); } else {