Merge lp:~luc-demeyer/account-financial-tools/add-account_move_line_search_extension into lp:~account-core-editors/account-financial-tools/7.0
- add-account_move_line_search_extension
- Merge into 7.0
Status: | Merged |
---|---|
Merged at revision: | 169 |
Proposed branch: | lp:~luc-demeyer/account-financial-tools/add-account_move_line_search_extension |
Merge into: | lp:~account-core-editors/account-financial-tools/7.0 |
Diff against target: |
263 lines (+225/-0) 6 files modified
account_move_line_search_extension/__init__.py (+22/-0) account_move_line_search_extension/__openerp__.py (+54/-0) account_move_line_search_extension/account_view.xml (+22/-0) account_move_line_search_extension/static/src/css/account_move_line_search_extension.css (+5/-0) account_move_line_search_extension/static/src/js/account_move_line_search_extension.js (+93/-0) account_move_line_search_extension/static/src/xml/account_move_line_search_extension.xml (+29/-0) |
To merge this branch: | bzr merge lp:~luc-demeyer/account-financial-tools/add-account_move_line_search_extension |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Yannick Vaucher @ Camptocamp | code review, no test | Approve | |
Guewen Baconnier @ Camptocamp | Approve | ||
Frederic Clementi - Camptocamp (community) | functional | Approve | |
Pedro Manuel Baeza | Abstain | ||
Review via email: mp+211967@code.launchpad.net |
Commit message
Description of the change
This module adds the 'Journal Items Search All' menu entry.
This menu entry adds a number of search fields on top of the List View rows.
These fields can be used in combination with the Search window.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
Pedro,
I made a separate view to avoid potential conflicts (now and in the future) between the javascript code in this module and the javascript code in the standard account module.
Also the use case for the two list views is different:
- The 'account' module list view has been extended with a (imho rather primitive) technique to facilitate the encoding of journal items.
- The 'move line search all' view is intended to facilitate the search through thousands/millions of journal items.
I hope that this small module can be discontinued in V8 and that we get again a "general, V6' type of search view that allows us to configure on any object what I have hardcoded in javascipt for one particular object.
Fabien has committed that V8 will come with an improved search view, hence I am looking forward to see what it will offer.
Regards,
Luc
www.noviat.com
Rusatiralaan 1, 1083 Brussel
+32 2 808 86 38
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Pedro Manuel Baeza
Sent: donderdag 20 maart 2014 16:21
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-tools/add-account_move_line_search_extension into lp:account-financial-tools
Review: Needs Information
Hi, Luc, thanks for the contribution,
It isn't better to extend current journal items view? Is there any blocking issue that prevents it?
Regards
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-tools/add-account_move_line_search_extension.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Thanks for the explanation, Luc.
As you have said, maybe this module in v8 is not needed, so I think it can be done with one view, but it's no so critical to block the MP for this.
I will test module later, so I mark it for now as Abstain to not interfere the MP with my "Needs information".
Regards.
Frederic Clementi - Camptocamp (frederic-clementi) wrote : | # |
I tested this module on a customer instance with 1 millions account move lines and it is working great. The search performance is very acceptable et on the ergonomic aspect it is a real improvement on day-to-day work for accountant.
Many thanks Luc for this contribution.
Frederic Clementi
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Hi,
Sounds good. It would be so nice to have autocompletion on the fields (but could be a new feature to add later, that's good enough now). I'm just wondering why the 'period' field is a char field and not a selection field like in the standard view, is it a usability reason?
Thanks
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
Period is a char field to facilitate the search on all periods in a given fiscal year (assuming of course that the fiscal year name is consistently used in the naming of the periods).
Luc
www.noviat.com
Rusatiralaan 1, 1083 Brussel
+32 2 808 86 38
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Guewen Baconnier @ Camptocamp
Sent: vrijdag 21 maart 2014 9:18
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-tools/add-account_move_line_search_extension into lp:account-financial-tools
Review: Needs Information code review, test
Hi,
Sounds good. It would be so nice to have autocompletion on the fields (but could be a new feature to add later, that's good enough now). I'm just wondering why the 'period' field is a char field and not a selection field like in the standard view, is it a usability reason?
Thanks
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-tools/add-account_move_line_search_extension.
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 03/24/2014 10:27 AM, Luc De Meyer (Noviat) wrote:
> Period is a char field to facilitate the search on all periods in a
> given fiscal year (assuming of course that the fiscal year name is
> consistently used in the naming of the periods).
>
> Luc
Nice, well thought!
Thanks
review approve
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://
iF4EAREIAAYFAlM
2v1Af93/
=M5xJ
-----END PGP SIGNATURE-----
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
LGTM
Preview Diff
1 | === added directory 'account_move_line_search_extension' |
2 | === added file 'account_move_line_search_extension/__init__.py' |
3 | --- account_move_line_search_extension/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ account_move_line_search_extension/__init__.py 2014-03-20 15:05:40 +0000 |
5 | @@ -0,0 +1,22 @@ |
6 | +# -*- encoding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# OpenERP, Open Source Management Solution |
10 | +# |
11 | +# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. |
12 | +# |
13 | +# This program is free software: you can redistribute it and/or modify |
14 | +# it under the terms of the GNU Affero General Public License as |
15 | +# published by the Free Software Foundation, either version 3 of the |
16 | +# License, or (at your option) any later version. |
17 | +# |
18 | +# This program is distributed in the hope that it will be useful, |
19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | +# GNU Affero General Public License for more details. |
22 | +# |
23 | +# You should have received a copy of the GNU Affero General Public License |
24 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | +# |
26 | +############################################################################## |
27 | + |
28 | |
29 | === added file 'account_move_line_search_extension/__openerp__.py' |
30 | --- account_move_line_search_extension/__openerp__.py 1970-01-01 00:00:00 +0000 |
31 | +++ account_move_line_search_extension/__openerp__.py 2014-03-20 15:05:40 +0000 |
32 | @@ -0,0 +1,54 @@ |
33 | +# -*- encoding: utf-8 -*- |
34 | +############################################################################## |
35 | +# |
36 | +# OpenERP, Open Source Management Solution |
37 | +# |
38 | +# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. |
39 | +# |
40 | +# This program is free software: you can redistribute it and/or modify |
41 | +# it under the terms of the GNU Affero General Public License as |
42 | +# published by the Free Software Foundation, either version 3 of the |
43 | +# License, or (at your option) any later version. |
44 | +# |
45 | +# This program is distributed in the hope that it will be useful, |
46 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
47 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
48 | +# GNU Affero General Public License for more details. |
49 | +# |
50 | +# You should have received a copy of the GNU Affero General Public License |
51 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
52 | +# |
53 | +############################################################################## |
54 | + |
55 | +{ |
56 | + 'name': 'Journal Items Search Extension', |
57 | + 'version': '0.1', |
58 | + 'license': 'AGPL-3', |
59 | + 'author': 'Noviat', |
60 | + 'category' : 'Generic Modules', |
61 | + 'description': """ |
62 | +Journal Items Search Extension |
63 | +============================== |
64 | + |
65 | +This module adds the 'Journal Items Search All' menu entry. |
66 | + |
67 | +This menu entry adds a number of search fields on top of the List View rows. |
68 | +These fields can be used in combination with the Search window. |
69 | + |
70 | + """, |
71 | + 'depends': ['account'], |
72 | + 'data' : [ |
73 | + 'account_view.xml', |
74 | + ], |
75 | + 'js': [ |
76 | + 'static/src/js/account_move_line_search_extension.js', |
77 | + ], |
78 | + 'qweb' : [ |
79 | + 'static/src/xml/account_move_line_search_extension.xml', |
80 | + ], |
81 | + 'css':[ |
82 | + 'static/src/css/account_move_line_search_extension.css', |
83 | + ], |
84 | + 'installable': True, |
85 | + 'auto_install': False, |
86 | +} |
87 | |
88 | === added file 'account_move_line_search_extension/account_view.xml' |
89 | --- account_move_line_search_extension/account_view.xml 1970-01-01 00:00:00 +0000 |
90 | +++ account_move_line_search_extension/account_view.xml 2014-03-20 15:05:40 +0000 |
91 | @@ -0,0 +1,22 @@ |
92 | +<?xml version="1.0" encoding="utf-8"?> |
93 | +<openerp> |
94 | + <data> |
95 | + |
96 | + <record id="action_account_move_line_search_extension" model="ir.actions.act_window"> |
97 | + <field name="context">{'account_move_line_search_extension':1}</field> |
98 | + <field name="name">Journal Items Search All</field> |
99 | + <field name="res_model">account.move.line</field> |
100 | + <field name="view_id" ref="account.view_move_line_tree"/> |
101 | + <field name="view_mode">account_move_line_search_extension,form</field> |
102 | + </record> |
103 | + <menuitem |
104 | + action="action_account_move_line_search_extension" |
105 | + icon="STOCK_JUSTIFY_FILL" |
106 | + id="menu_account_move_line_search_extension" |
107 | + parent="account.menu_finance_entries" |
108 | + sequence="1" |
109 | + groups="account.group_account_user" |
110 | + /> |
111 | + |
112 | + </data> |
113 | +</openerp> |
114 | |
115 | === added directory 'account_move_line_search_extension/static' |
116 | === added directory 'account_move_line_search_extension/static/src' |
117 | === added directory 'account_move_line_search_extension/static/src/css' |
118 | === added file 'account_move_line_search_extension/static/src/css/account_move_line_search_extension.css' |
119 | --- account_move_line_search_extension/static/src/css/account_move_line_search_extension.css 1970-01-01 00:00:00 +0000 |
120 | +++ account_move_line_search_extension/static/src/css/account_move_line_search_extension.css 2014-03-20 15:05:40 +0000 |
121 | @@ -0,0 +1,5 @@ |
122 | +.openerp .oe_form_char_section { |
123 | + position: relative; |
124 | + display: inline-block; |
125 | +} |
126 | + |
127 | |
128 | === added directory 'account_move_line_search_extension/static/src/img' |
129 | === added file 'account_move_line_search_extension/static/src/img/icon.png' |
130 | Binary files account_move_line_search_extension/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and account_move_line_search_extension/static/src/img/icon.png 2014-03-20 15:05:40 +0000 differ |
131 | === added directory 'account_move_line_search_extension/static/src/js' |
132 | === added file 'account_move_line_search_extension/static/src/js/account_move_line_search_extension.js' |
133 | --- account_move_line_search_extension/static/src/js/account_move_line_search_extension.js 1970-01-01 00:00:00 +0000 |
134 | +++ account_move_line_search_extension/static/src/js/account_move_line_search_extension.js 2014-03-20 15:05:40 +0000 |
135 | @@ -0,0 +1,93 @@ |
136 | +openerp.account_move_line_search_extension = function (instance) { |
137 | + var _t = instance.web._t, |
138 | + _lt = instance.web._lt; |
139 | + var QWeb = instance.web.qweb; |
140 | + |
141 | + instance.account_move_line_search_extension = {}; |
142 | + |
143 | + instance.web.views.add('account_move_line_search_extension', 'instance.account_move_line_search_extension.ListSearchView'); |
144 | + instance.account_move_line_search_extension.ListSearchView = instance.web.ListView.extend({ |
145 | + |
146 | + init: function() { |
147 | + this._super.apply(this, arguments); |
148 | + this.journals = []; |
149 | + this.current_account = null; |
150 | + this.current_partner = null; |
151 | + this.current_journal = null; |
152 | + this.current_period = null; |
153 | + }, |
154 | + |
155 | + start:function(){ |
156 | + var tmp = this._super.apply(this, arguments); |
157 | + var self = this; |
158 | + this.$el.parent().prepend(QWeb.render('AccountMoveLineSearchExtension', {widget: this})); |
159 | + |
160 | + this.$el.parent().find('.oe_account_select_account').change(function() { |
161 | + self.current_account = this.value === '' ? null : this.value; |
162 | + self.do_search(self.last_domain, self.last_context, self.last_group_by); |
163 | + }); |
164 | + this.$el.parent().find('.oe_account_select_partner').change(function() { |
165 | + self.current_partner = this.value === '' ? null : this.value; |
166 | + self.do_search(self.last_domain, self.last_context, self.last_group_by); |
167 | + }); |
168 | + this.$el.parent().find('.oe_account_select_journal').change(function() { |
169 | + self.current_journal = this.value === '' ? null : parseInt(this.value); |
170 | + //console.log('start, oasj, self.current_journal=', self.current_journal, 'self.last_domain=', self.last_domain, 'self.last_context=', self.last_context, 'self.last_group_by=', self.last_group_by); |
171 | + self.do_search(self.last_domain, self.last_context, self.last_group_by); |
172 | + }); |
173 | + this.$el.parent().find('.oe_account_select_period').change(function() { |
174 | + self.current_period = this.value === '' ? null : this.value; |
175 | + self.do_search(self.last_domain, self.last_context, self.last_group_by); |
176 | + }); |
177 | + this.on('edit:after', this, function () { |
178 | + self.$el.parent().find('.oe_account_select_account').attr('disabled', 'disabled'); |
179 | + self.$el.parent().find('.oe_account_select_partner').attr('disabled', 'disabled'); |
180 | + self.$el.parent().find('.oe_account_select_journal').attr('disabled', 'disabled'); |
181 | + self.$el.parent().find('.oe_account_select_period').attr('disabled', 'disabled'); |
182 | + }); |
183 | + this.on('save:after cancel:after', this, function () { |
184 | + self.$el.parent().find('.oe_account_select_account').removeAttr('disabled'); |
185 | + self.$el.parent().find('.oe_account_select_partner').removeAttr('disabled'); |
186 | + self.$el.parent().find('.oe_account_select_journal').removeAttr('disabled'); |
187 | + self.$el.parent().find('.oe_account_select_period').removeAttr('disabled'); |
188 | + }); |
189 | + return tmp; |
190 | + }, |
191 | + |
192 | + do_search: function(domain, context, group_by) { |
193 | + var self = this; |
194 | + this.last_domain = domain; |
195 | + this.last_context = context; |
196 | + this.last_group_by = group_by; |
197 | + this.old_search = _.bind(this._super, this); |
198 | + var aj_mod = new instance.web.Model('account.journal'); |
199 | + return $.when(aj_mod.query(['name']).all().then(function(result) { |
200 | + self.journals = result; |
201 | + })).then(function () { |
202 | + var o; |
203 | + self.$el.parent().find('.oe_account_select_journal').children().remove().end(); |
204 | + self.$el.parent().find('.oe_account_select_journal').append(new Option('', '')); |
205 | + for (var i = 0;i < self.journals.length;i++){ |
206 | + o = new Option(self.journals[i].name, self.journals[i].id); |
207 | + if (self.journals[i].id === self.current_journal){ |
208 | + $(o).attr('selected',true); |
209 | + } |
210 | + self.$el.parent().find('.oe_account_select_journal').append(o); |
211 | + } |
212 | + return self.search_by_selection(); |
213 | + }); |
214 | + }, |
215 | + |
216 | + search_by_selection: function() { |
217 | + var self = this; |
218 | + var domain = []; |
219 | + if (self.current_account) domain.push(['account_id.code', 'ilike', self.current_account]); |
220 | + if (self.current_partner) domain.push(['partner_id.name', 'ilike', self.current_partner],'|',['partner_id.parent_id','=',false],['partner_id.is_company','=',true]); |
221 | + if (self.current_journal) domain.push(['journal_id', '=', self.current_journal]); |
222 | + if (self.current_period) domain.push('|',['period_id.code', 'ilike', self.current_period],['period_id.name', 'ilike', self.current_period]); |
223 | + //_.each(domain, function(x) {console.log('search_by_journal_period, domain_part = ', x)}); |
224 | + return self.old_search(new instance.web.CompoundDomain(self.last_domain, domain), self.last_context, self.last_group_by); |
225 | + }, |
226 | + |
227 | + }); |
228 | +}; |
229 | |
230 | === added directory 'account_move_line_search_extension/static/src/xml' |
231 | === added file 'account_move_line_search_extension/static/src/xml/account_move_line_search_extension.xml' |
232 | --- account_move_line_search_extension/static/src/xml/account_move_line_search_extension.xml 1970-01-01 00:00:00 +0000 |
233 | +++ account_move_line_search_extension/static/src/xml/account_move_line_search_extension.xml 2014-03-20 15:05:40 +0000 |
234 | @@ -0,0 +1,29 @@ |
235 | +<?xml version="1.0" encoding="UTF-8"?> |
236 | +<templates id="template" xml:space="preserve"> |
237 | + |
238 | + <t t-name="AccountMoveLineSearchExtension"> |
239 | + <div class="ui-toolbar" style="margin-bottom:0px;"> |
240 | + <div class="oe_form_char_section"> |
241 | + <h4>Account :</h4> |
242 | + <input type="text" class="oe_account_select_account"> |
243 | + </input> |
244 | + </div> |
245 | + <div class="oe_form_char_section"> |
246 | + <h4>Partner :</h4> |
247 | + <input type="text" class="oe_account_select_partner"> |
248 | + </input> |
249 | + </div> |
250 | + <div class="oe_form_dropdown_section"> |
251 | + <h4>Journal :</h4> |
252 | + <select class="oe_account_select_journal"> |
253 | + </select> |
254 | + </div> |
255 | + <div class="oe_form_char_section"> |
256 | + <h4>Period :</h4> |
257 | + <input type="text" class="oe_account_select_period"> |
258 | + </input> |
259 | + </div> |
260 | + </div> |
261 | + </t> |
262 | + |
263 | +</templates> |
Hi, Luc, thanks for the contribution,
It isn't better to extend current journal items view? Is there any blocking issue that prevents it?
Regards