Browse Source

Merge pull request #122 from hbrunn/7.0-advanced_filters-public

[IMP] let user decide if a filter is private when saving it
pull/225/head
Sylvain LE GAL 9 years ago
parent
commit
91abe98605
  1. 5
      web_advanced_filters/i18n/nl.po
  2. 14
      web_advanced_filters/model/ir_filters.py
  3. 2
      web_advanced_filters/static/src/js/web_advanced_filters.js
  4. 1
      web_advanced_filters/view/ir_filters.xml
  5. 4
      web_advanced_filters/wizard/ir_filters_combine_with_existing.py

5
web_advanced_filters/i18n/nl.po

@ -60,6 +60,11 @@ msgstr "Testen %s"
msgid "or" msgid "or"
msgstr "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 #. module: web_advanced_filters
#: field:ir.filters,complement_filter_ids:0 #: field:ir.filters,complement_filter_ids:0
msgid "Remove result of filters" msgid "Remove result of filters"

14
web_advanced_filters/model/ir_filters.py

@ -164,11 +164,18 @@ class IrFilters(Model):
_evaluate_get, type='boolean', multi='evaluate', _evaluate_get, type='boolean', multi='evaluate',
string='Always evaluate this filter before using it', string='Always evaluate this filter before using it',
help='This is necessary if this filter contains x2many fields with' 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 = { _defaults = {
'active': True, 'active': True,
'save_as_public': False,
} }
def _evaluate(self, cr, uid, ids, context=None): def _evaluate(self, cr, uid, ids, context=None):
@ -245,3 +252,8 @@ class IrFilters(Model):
"update ir_module_module set state='to remove' where " "update ir_module_module set state='to remove' where "
"name='advanced_filters' and state not in " "name='advanced_filters' and state not in "
"('uninstalled', 'to remove')") "('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)

2
web_advanced_filters/static/src/js/web_advanced_filters.js

@ -171,6 +171,7 @@ openerp.web_advanced_filters = function(instance)
default_model_id: self.dataset._model.name, default_model_id: self.dataset._model.name,
default_domain: JSON.stringify(search.domain), default_domain: JSON.stringify(search.domain),
default_context: JSON.stringify(ctx), default_context: JSON.stringify(ctx),
default_user_id: JSON.stringify(false),
form_view_ref: 'web_advanced_filters.form_ir_filters_save_new', form_view_ref: 'web_advanced_filters.form_ir_filters_save_new',
}, },
}, },
@ -201,6 +202,7 @@ openerp.web_advanced_filters = function(instance)
] ]
), ),
default_context: JSON.stringify({}), default_context: JSON.stringify({}),
default_user_id: JSON.stringify(false),
form_view_ref: 'web_advanced_filters.form_ir_filters_save_new', form_view_ref: 'web_advanced_filters.form_ir_filters_save_new',
}, },
}, },

1
web_advanced_filters/view/ir_filters.xml

@ -37,6 +37,7 @@
<group> <group>
<field name="name" /> <field name="name" />
<field name="is_default"/> <field name="is_default"/>
<field name="save_as_public" />
</group> </group>
<footer> <footer>
<button class="oe_highlight" type="object" name="button_save" string="Save" /> <button class="oe_highlight" type="object" name="button_save" string="Save" />

4
web_advanced_filters/wizard/ir_filters_combine_with_existing.py

@ -62,7 +62,7 @@ class IrFiltersCombineWithExisting(TransientModel):
'domain': str(domain), 'domain': str(domain),
'context': this.context, 'context': this.context,
'model_id': this.model, 'model_id': this.model,
'user_id': uid,
'user_id': this.filter_id.user_id.id or False,
})], })],
}) })
elif this.action == 'complement': elif this.action == 'complement':
@ -81,7 +81,7 @@ class IrFiltersCombineWithExisting(TransientModel):
'domain': str(domain), 'domain': str(domain),
'context': this.context, 'context': this.context,
'model_id': this.model, 'model_id': this.model,
'user_id': uid,
'user_id': this.filter_id.user_id.id or False,
})], })],
}) })

Loading…
Cancel
Save