Merge lp:~openerp-dev/openobject-client/duplication_of_ir.filters into lp:openobject-client

Proposed by Ravi Gadhia (OpenERP)
Status: Rejected
Rejected by: Naresh(OpenERP)
Proposed branch: lp:~openerp-dev/openobject-client/duplication_of_ir.filters
Merge into: lp:openobject-client
Diff against target: 155 lines (+57/-13)
3 files modified
bin/widget/screen/screen.py (+34/-8)
bin/widget/view/list.py (+1/-1)
bin/widget/view/screen_container.py (+22/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-client/duplication_of_ir.filters
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Needs Fixing
Olivier Dony (Odoo) Approve
Review via email: mp+35990@code.launchpad.net

Description of the change

hello,
In order to make ir.filter more user-friendly the filter name should be specified already in the dialog box if the user tries to save a (active)filter and another filter is already active/selected

related server branch is: lp:~openerp-dev/openobject-server/remove_duplication_of_ir.filters

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,
* The text(any existing....) should be under the textbox.
* The label should only be Filter Name:
* Code Refactoring is needed.
* No need of additional type to be added in the liststore.

Thanks

review: Needs Fixing
1566. By Ravi Gadhia (OpenERP)

[REF] Remove addition int type from combo liststore,improve view of dialog box

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Ok for merge if NCH approves now, the server branch has been merged so it's ready on server-side

review: Approve
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,
It doesn't work for the following cases:

Case 1:Context not updated
       Step 1:create a filter on SO say group by customer. Save this filter as 'Filter A'
       Step 2: now clear everything and execute the 'Filter A'.
       Step 3: add new Domain to this filter by pressing 'To invoice' button.
       Step 4: save the filter. you will be prompted with 'Filter A' name click ok to save. IMHO This
               should add the new Domain to the 'Filter A'.
       Step 5: clear everything. and execute 'Filter A'. You will see the Group by has Disappeared,
               only the domain is there in 'Filter A'.

Case 2:After Saving the filter the combobox should show the newly created filter Name as selected because the records are shown in the list view with the newly created filter.

* String 'Filter Name' align it to the left.

Thanks

review: Needs Fixing
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

> Case 1:Context not updated
> Step 1:create a filter on SO say group by customer. Save this filter as
> 'Filter A'
> Step 2: now clear everything and execute the 'Filter A'.
> Step 3: add new Domain to this filter by pressing 'To invoice' button.
> Step 4: save the filter. you will be prompted with 'Filter A' name
> click ok to save. IMHO This
> should add the new Domain to the 'Filter A'.
> Step 5: clear everything. and execute 'Filter A'. You will see the
> Group by has Disappeared,
> only the domain is there in 'Filter A'.

Yes, good point: when calling create_or_replace() the domain and context passed should be the full domain and context currently applied, so it needs to be merged with the domain and context from the selected filter if there is one.

> Case 2:After Saving the filter the combobox should show the newly created
> filter Name as selected because the records are shown in the list view with
> the newly created filter.

Ah yes, why not. In fact the search fields will also contain the current filter if it is a new one, but the worst that can happen is that the domain that is passed to search() will have duplicated entries, which is ok I guess.. (cleaning duplicate entries is not trivial)

1567. By Ravi Gadhia (OpenERP)

[Fix] New Created filter name should be dispay on combobox

1568. By Ravi Gadhia (OpenERP)

Merge with trunk

1569. By Ravi Gadhia (OpenERP)

[Fix] domain/context should be update when filter replace

1570. By Ravi Gadhia (OpenERP)

[Fix] block change signal on clearing model of search filter combobox

1571. By Ravi Gadhia (OpenERP)

[fix] group_by_no_leaf filter crash on clear

1572. By Ravi Gadhia (OpenERP)

Merge with trunk

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Unmerged revisions

1572. By Ravi Gadhia (OpenERP)

Merge with trunk

1571. By Ravi Gadhia (OpenERP)

[fix] group_by_no_leaf filter crash on clear

1570. By Ravi Gadhia (OpenERP)

[Fix] block change signal on clearing model of search filter combobox

1569. By Ravi Gadhia (OpenERP)

[Fix] domain/context should be update when filter replace

1568. By Ravi Gadhia (OpenERP)

Merge with trunk

1567. By Ravi Gadhia (OpenERP)

[Fix] New Created filter name should be dispay on combobox

1566. By Ravi Gadhia (OpenERP)

[REF] Remove addition int type from combo liststore,improve view of dialog box

1565. By Ravi Gadhia (OpenERP)

[IMP]set active filter name in create filter dialog box

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/widget/screen/screen.py'
2--- bin/widget/screen/screen.py 2010-10-12 06:12:38 +0000
3+++ bin/widget/screen/screen.py 2010-10-12 11:14:46 +0000
4@@ -309,6 +309,9 @@
5
6 def execute_action(self, combo):
7 flag = combo.get_active_text()
8+ combo_model = combo.get_model()
9+ active_id = combo.get_active()
10+ action_name = active_id != -1 and flag not in ['mf','blk','sh', 'sf'] and combo_model[active_id][2]
11 # 'mf' Section manages Filters
12 def clear_domain_ctx():
13 for key in self.old_ctx.keys():
14@@ -334,6 +337,7 @@
15 value = obj._exec_action(act, {}, ctx)
16
17 if flag in ['blk','mf']:
18+ self.screen_container.last_active_filter = False
19 clear_domain_ctx()
20 self.search_filter()
21 combo.set_active(0)
22@@ -344,10 +348,19 @@
23 widget = glade2.get_widget('action_name')
24 win = glade2.get_widget('dia_get_action')
25 win.set_icon(common.OPENERP_ICON)
26+ lbl = glade2.get_widget('label157')
27 if flag == 'sh':
28 win.set_title('Shortcut Entry')
29- lbl = glade2.get_widget('label157')
30- lbl.set_text('Enter Shortcut Name:')
31+ lbl.set_text('Shortcut Name:')
32+ else:
33+ win.set_size_request(300, 165)
34+ text_entry = glade2.get_widget('action_name')
35+ lbl.set_text('Filter Name:')
36+ table = glade2.get_widget('table8')
37+ info_lbl = gtk.Label('(Any existing filter with the \nsame name will be replaced)')
38+ table.attach(info_lbl,1,2,2,3, gtk.FILL, gtk.EXPAND)
39+ if self.screen_container.last_active_filter:
40+ text_entry.set_text(self.screen_container.last_active_filter)
41 win.show_all()
42 response = win.run()
43 # grab a safe copy of the entered text before destroy() to avoid GTK bug https://bugzilla.gnome.org/show_bug.cgi?id=613241
44@@ -355,22 +368,35 @@
45 win.destroy()
46 combo.set_active(0)
47 if response == gtk.RESPONSE_OK and action_name:
48+ filter_domain = self.filter_widget and self.filter_widget.value.get('domain',[])
49+ filter_context = self.filter_widget and self.filter_widget.value.get('context',{})
50 values = {'name':action_name,
51 'model_id':self.name,
52- 'domain':str(self.filter_widget and self.filter_widget.value.get('domain',[])),
53- 'context':str(self.filter_widget and self.filter_widget.value.get('context',{})),
54 'user_id':rpc.session.uid
55 }
56 if flag == 'sf':
57- action_id = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.filters', 'create', values, self.context)
58- self.screen_container.fill_filter_combo(self.name)
59+ domain, context = self.screen_container.get_filter(action_name)
60+ for dom in eval(domain):
61+ if dom not in filter_domain:
62+ filter_domain.append(dom)
63+ groupby_list = eval(context).get('group_by',[]) + filter_context.get('group_by',[])
64+ filter_context.update(eval(context))
65+ filter_context.update({'group_by':groupby_list})
66+ values.update({'domain':str(filter_domain),
67+ 'context':str(filter_context),
68+ })
69+ action_id = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.filters', 'create_or_replace', values, self.context)
70+ self.screen_container.fill_filter_combo(self.name, action_name)
71 if flag == 'sh':
72 values.update({'res_model':self.name,
73- 'search_view_id':self.search_view['view_id'],
74- 'default_user_ids': [[6, 0, [rpc.session.uid]]]})
75+ 'domain':str(filter_domain),
76+ 'context':str(filter_context),
77+ 'search_view_id':self.search_view['view_id'],
78+ 'default_user_ids': [[6, 0, [rpc.session.uid]]]})
79 rpc.session.rpc_exec_auth_try('/object', 'execute', 'ir.ui.menu', 'create_shortcut', values, self.context)
80 else:
81 try:
82+ self.screen_container.last_active_filter = action_name
83 filter_domain = flag and tools.expr_eval(flag)
84 clear_domain_ctx()
85 if combo.get_active() >= 0:
86
87=== modified file 'bin/widget/view/list.py'
88--- bin/widget/view/list.py 2010-10-12 10:14:15 +0000
89+++ bin/widget/view/list.py 2010-10-12 11:14:46 +0000
90@@ -122,7 +122,7 @@
91 if self.loaded:
92 return
93 self.loaded = True
94- gb = self.context.get('group_by', False)
95+ gb = self.context.get('group_by', [])
96 no_leaf = self.context.get('group_by_no_leaf', False)
97 if gb or no_leaf:
98 records = rpc.session.rpc_exec_auth('/object', 'execute', self.mgroup.resource, 'read_group',
99
100=== modified file 'bin/widget/view/screen_container.py'
101--- bin/widget/view/screen_container.py 2010-10-12 06:12:38 +0000
102+++ bin/widget/view/screen_container.py 2010-10-12 11:14:46 +0000
103@@ -36,6 +36,7 @@
104 self.vp = gtk.Viewport()
105 self.vp.set_shadow_type(gtk.SHADOW_NONE)
106 self.vbox = gtk.VBox()
107+ self.last_active_filter = False
108 self.vbox.pack_end(self.sw)
109 self.filter_vbox = None
110 self.button = None
111@@ -48,23 +49,40 @@
112 def widget_get(self):
113 return self.vbox
114
115- def fill_filter_combo(self, model):
116+ def fill_filter_combo(self, model, action_name = False):
117+ self.action_combo.handler_block(self.handler_id)
118 self.action_list.clear()
119+ self.action_combo.handler_unblock(self.handler_id)
120+ active = False
121 my_acts = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.filters', 'get_filters', model)
122 filters_list=[['blk','','-- Filters --']]
123 sorted_filters = [[act.get('domain',act['id']),act['context'],act['name']] for act in my_acts]
124 sorted_filters.sort(lambda x, y: cmp(x[2], y[2]))
125 filters_list += sorted_filters
126 filters_list += [['blk','','--Actions--'],['sh','','Save as a Shortcut'],['sf','','Save as a Filter'],['mf','','Manage Filters']]
127- for lim in filters_list:
128- self.action_list.append(lim)
129- self.action_combo.set_active(0)
130+ for index, action in enumerate(filters_list):
131+ if action[-1] == action_name:
132+ active = index
133+ self.action_list.append(action)
134+ if active:
135+ self.action_combo.set_active(active)
136+ else:
137+ self.action_combo.set_active(0)
138+
139
140 def fill_limit_combo(self):
141 self.limit_combo.clear()
142 for lim in [[100,'100'],[200,'200'],[500,'500'],[None,'Unlimited']]:
143 self.limit_combo.append(lim)
144 self.combo.set_active(0)
145+
146+
147+ def get_filter(self, filter_name):
148+ def fnct(filterstore, path, iter, filter_name):
149+ if filterstore.get(iter, 2)[0].lower() == filter_name.lower() and not self.domain and not self.context:
150+ self.domain, self.context = filterstore.get(iter, 0, 1)
151+ self.action_list.foreach(fnct, filter_name)
152+ return str(self.domain),str(self.context)
153
154 def add_filter(self, widget, fnct, clear_fnct, next_fnct, prev_fnct, execute_action=None, add_custom=None, model=None, limit=100):
155 self.filter_vbox = gtk.VBox(spacing=1)