Merge lp:~openerp-dev/openobject-server/trunk-customfilter-jir into lp:openobject-server

Proposed by Jignesh Rathod(OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/trunk-customfilter-jir
Merge into: lp:openobject-server
Diff against target: 83 lines (+12/-5)
2 files modified
openerp/addons/base/ir/ir_filters.py (+10/-5)
openerp/addons/base/ir/ir_filters.xml (+2/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-customfilter-jir
Reviewer Review Type Date Requested Status
Priyesh (OpenERP) Pending
Review via email: mp+170813@code.launchpad.net

Description of the change

Custom filter for default action.

To post a comment you must log in.
4898. By Jignesh Rathod(OpenERP)

Merge With latest trunk.

4899. By Jignesh Rathod(OpenERP)

Merge with latest code.

4900. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4901. By Vidhin Mehta (OpenERP)

[MERGE]latest

4902. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

Revision history for this message
Antony Lesuisse (OpenERP) (al-openerp) wrote :

rename action -> action_id

4903. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4904. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4905. By Vidhin Mehta (OpenERP)

[IMP]action -> action id.

4906. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4907. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

Unmerged revisions

4907. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4906. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4905. By Vidhin Mehta (OpenERP)

[IMP]action -> action id.

4904. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4903. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4902. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4901. By Vidhin Mehta (OpenERP)

[MERGE]latest

4900. By Vidhin Mehta (OpenERP)

[MERGE]Trunk.

4899. By Jignesh Rathod(OpenERP)

Merge with latest code.

4898. By Jignesh Rathod(OpenERP)

Merge With latest trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/ir/ir_filters.py'
2--- openerp/addons/base/ir/ir_filters.py 2014-05-01 18:42:17 +0000
3+++ openerp/addons/base/ir/ir_filters.py 2014-06-10 10:26:27 +0000
4@@ -36,16 +36,16 @@
5 default.update({'name':_('%s (copy)') % name})
6 return super(ir_filters, self).copy(cr, uid, id, default, context)
7
8- def get_filters(self, cr, uid, model):
9+ def get_filters(self, cr, uid, model, action_id=None):
10 """Obtain the list of filters available for the user on the given model.
11
12 :return: list of :meth:`~osv.read`-like dicts containing the
13 ``name``, ``is_default``, ``domain``, ``user_id`` (m2o tuple) and
14 ``context`` of the matching ``ir.filters``.
15 """
16- # available filters: private filters (user_id=uid) and public filters (uid=NULL)
17+ # available filters: private filters (user_id=uid) and public filters (uid=NULL)
18 filter_ids = self.search(cr, uid,
19- [('model_id','=',model),('user_id','in',[uid, False])])
20+ [('model_id','=',model),('user_id','in',[uid, False]),('action_id', '=', action_id)])
21 my_filters = self.read(cr, uid, filter_ids,
22 ['name', 'is_default', 'domain', 'context', 'user_id'])
23 return my_filters
24@@ -66,9 +66,11 @@
25 :raises openerp.exceptions.Warning: if there is an existing default and
26 we're not updating it
27 """
28+ action_id = vals.get('action_id', False)
29 existing_default = self.search(cr, uid, [
30 ('model_id', '=', vals['model_id']),
31 ('user_id', '=', False),
32+ ('action_id', '=', action_id),
33 ('is_default', '=', True)], context=context)
34
35 if not existing_default: return
36@@ -83,7 +85,8 @@
37
38 def create_or_replace(self, cr, uid, vals, context=None):
39 lower_name = vals['name'].lower()
40- matching_filters = [f for f in self.get_filters(cr, uid, vals['model_id'])
41+ action_id = vals.get('action_id', False)
42+ matching_filters = [f for f in self.get_filters(cr, uid, vals['model_id'], action_id)
43 if f['name'].lower() == lower_name
44 # next line looks for matching user_ids (specific or global), i.e.
45 # f.user_id is False and vals.user_id is False or missing,
46@@ -95,6 +98,7 @@
47 act_ids = self.search(cr, uid, [
48 ('model_id', '=', vals['model_id']),
49 ('user_id', '=', vals['user_id']),
50+ ('action_id', '=', action_id),
51 ('is_default', '=', True),
52 ], context=context)
53 self.write(cr, uid, act_ids, {'is_default': False}, context=context)
54@@ -133,7 +137,8 @@
55 'domain': fields.text('Domain', required=True),
56 'context': fields.text('Context', required=True),
57 'model_id': fields.selection(_list_all_models, 'Model', required=True),
58- 'is_default': fields.boolean('Default filter')
59+ 'is_default': fields.boolean('Default filter'),
60+ 'action_id': fields.many2one('ir.actions.actions', 'Action', ondelete='cascade', help="Default Action")
61 }
62 _defaults = {
63 'domain': '[]',
64
65=== modified file 'openerp/addons/base/ir/ir_filters.xml'
66--- openerp/addons/base/ir/ir_filters.xml 2013-04-29 12:24:23 +0000
67+++ openerp/addons/base/ir/ir_filters.xml 2014-06-10 10:26:27 +0000
68@@ -20,6 +20,7 @@
69 <field name="user_id"/>
70 <field name="model_id"/>
71 <field name="is_default"/>
72+ <field name="action_id"/>
73 </group>
74 <group>
75 <field name="domain"/>
76@@ -37,6 +38,7 @@
77 <field name="model_id"/>
78 <field name="user_id"/>
79 <field name="is_default"/>
80+ <field name="action_id"/>
81 <field name="domain" groups="base.group_no_one"/>
82 <field name="context" groups="base.group_no_one"/>
83 </tree>