From a7c29dfe49c138e9e03c2391f1b6a14f31ad9a8a Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 20 Apr 2015 14:03:03 +0200 Subject: [PATCH] [IMP] use same UI as when saving a normal filter --- web_advanced_filters/i18n/nl.po | 5 +++++ web_advanced_filters/model/ir_filters.py | 14 +++++++++++++- web_advanced_filters/view/ir_filters.xml | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/web_advanced_filters/i18n/nl.po b/web_advanced_filters/i18n/nl.po index 45026482..9445741d 100644 --- a/web_advanced_filters/i18n/nl.po +++ b/web_advanced_filters/i18n/nl.po @@ -60,6 +60,11 @@ msgstr "Testen %s" msgid "or" msgstr "or" +#. module: web_advanced_filters +#: field:ir.filters,save_as_public:0 +msgid "Share with all users" +msgstr "Deel met alle gebruikers" + #. module: web_advanced_filters #: field:ir.filters,complement_filter_ids:0 msgid "Remove result of filters" diff --git a/web_advanced_filters/model/ir_filters.py b/web_advanced_filters/model/ir_filters.py index 488c5a02..6c4058ab 100644 --- a/web_advanced_filters/model/ir_filters.py +++ b/web_advanced_filters/model/ir_filters.py @@ -164,11 +164,18 @@ class IrFilters(Model): _evaluate_get, type='boolean', multi='evaluate', string='Always evaluate this filter before using it', help='This is necessary if this filter contains x2many fields with' - '_auto_join activated') + '_auto_join activated'), + 'save_as_public': fields.function( + lambda self, cr, uid, ids, *args, **kwargs: + dict((i, False) for i in ids), + fnct_inv=lambda *args, **kwargs: None, + type='boolean', + string='Share with all users'), } _defaults = { 'active': True, + 'save_as_public': False, } def _evaluate(self, cr, uid, ids, context=None): @@ -245,3 +252,8 @@ class IrFilters(Model): "update ir_module_module set state='to remove' where " "name='advanced_filters' and state not in " "('uninstalled', 'to remove')") + + def create(self, cr, uid, values, context=None): + values.setdefault( + 'user_id', False if values.get('save_as_public') else uid) + return super(IrFilters, self).create(cr, uid, values, context=context) diff --git a/web_advanced_filters/view/ir_filters.xml b/web_advanced_filters/view/ir_filters.xml index 10c1f327..4054aade 100644 --- a/web_advanced_filters/view/ir_filters.xml +++ b/web_advanced_filters/view/ir_filters.xml @@ -37,7 +37,7 @@ - +