Merge lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls into lp:~account-report-core-editor/account-financial-report/7.0
- 7.0-account_move_line_report_xls
- Merge into 7.0
Status: | Merged |
---|---|
Approved by: | Alexandre Fayolle - camptocamp |
Approved revision: | 57 |
Merged at revision: | 64 |
Proposed branch: | lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls |
Merge into: | lp:~account-report-core-editor/account-financial-report/7.0 |
Diff against target: |
678 lines (+629/-0) 8 files modified
account_move_line_report_xls/__init__.py (+24/-0) account_move_line_report_xls/__openerp__.py (+46/-0) account_move_line_report_xls/account_move_line.py (+52/-0) account_move_line_report_xls/i18n/fr.po (+111/-0) account_move_line_report_xls/i18n/nl.po (+111/-0) account_move_line_report_xls/report/__init__.py (+23/-0) account_move_line_report_xls/report/move_line_list_xls.py (+240/-0) account_move_line_report_xls/report/move_line_list_xls.xml (+22/-0) |
To merge this branch: | bzr merge lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandre Fayolle - camptocamp | code review, no test | Approve | |
Frederic Clementi - Camptocamp | functional | Approve | |
Maxime Chambreuil (http://www.savoirfairelinux.com) | code review | Approve | |
Alexis de Lattre (community) | Approve | ||
Review via email: mp+192250@code.launchpad.net |
Commit message
Description of the change
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote : | # |
- 56. By Luc De Meyer
-
technical update
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
I have updated branch https:/
Regards,
Luc
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Alexandre Fayolle - camptocamp
Sent: donderdag 24 oktober 2013 10:13
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls into lp:account-financial-report
Review: Needs Fixing code review, no test
Could you take the time to bring this to the 7.0 community addons coding conventions. This includes:
* not using the shortcut imports (things in the openerp namespace need to be imported from openerp)
* using the from . import xxx for relative imports (typically in __init__.py files)
* using orm.Model and orm.TransientModel as base class rather than osv.osv and osv.osv_memory
* not instanciating the model classes
* following PEP8 for spacing, line wrapping, etc.
Nice to have would be a couple of automated tests exercising the code.
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Hi, Luc, when report_xls will be available on https:/
"If you are installing this module manually, you need also the module 'report_xls', that is located in:
https:/
Regards.
Alexis de Lattre (alexis-via) wrote : | # |
It is definitely a great module.
But I just found a bug : if you inherit _report_
Traceback (most recent call last):
File "/home/
(result, format) = obj.create(cr, uid, ids, datas, context)
File "/home/
return self.create_
File "/home/
self.
File "/home/
debit_cell = rowcol_
UnboundLocalError: local variable 'debit_pos' referenced before assignment
Alexis de Lattre (alexis-via) wrote : | # |
@Luc
I have prepared a small patch that you can find here :
http://
It adds several fields (journal, analytic_account, company_currency, other_currency, other_currency_
Alexis de Lattre (alexis-via) wrote : | # |
About the crash that I mentionned 2 comments above, the reason is quite obvious when you look at the code in report/
if 'balance' in wanted_list':
and then it is used in a block of code which is executed in all cases.
- 57. By Luc De Meyer
-
translations, extra fields, better inheritance support
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
Alexis,
We already fixed this problems in the version that you find on our V7 "apps.openerp.com" launchpad branch, cf. ~noviat/
This version also extends the inherit concept to add new fields (in order to support add-on modules that add account_move_line fields and also add french and dutch translations).
I have uploaded the new version to https:/
Regards,
Luc
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Alexis de Lattre
Sent: zaterdag 14 december 2013 0:17
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls into lp:account-financial-report
About the crash that I mentionned 2 comments above, the reason is quite obvious when you look at the code in report/
if 'balance' in wanted_list':
and then it is used in a block of code which is executed in all cases.
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls.
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
Alexis,
Cf. our update on https:/
The "other_currency, other_currency_
I have added the journal, analytic_account, company_currency fields from your merge proposal.
You will also remark that the XLS template can now be customised via an inherited module hence 'account_move_line' fields added by OpenERP or Community addons can be added to the XLS export in a few minutes.
Regards,
Luc
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Alexis de Lattre
Sent: vrijdag 13 december 2013 16:35
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls into lp:account-financial-report
@Luc
I have prepared a small patch that you can find here :
http://
It adds several fields (journal, analytic_account, company_currency, other_currency, other_currency_
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls.
Alexis de Lattre (alexis-via) wrote : | # |
Luc,
Thank you for taking into account my patch and fixing the bug !
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) : | # |
Frederic Clementi - Camptocamp (frederic-clementi) wrote : | # |
Is the analytical account still missing in this version ?
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
Analytic account is available in this version.
Luc
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Frederic Clementi - Camptocamp
Sent: maandag 6 januari 2014 12:14
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls into lp:account-financial-report
Review: Needs Fixing functional
Is the analytical account still missing in this version ?
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls.
Alexis de Lattre (alexis-via) wrote : | # |
Yes, it is available, but it is not displayed by default in the XLS report, cf the fonction _report_
I think that we should add 2 fields in the default report :
- analytic account
- journal code
What do you think ?
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
We have installed this module in the meanwhile at most of our customers and requirements vary from customer to customer which makes it difficult to decide upon the default fields but adding journal & analytic certainly makes sense.
If no objection, I propose to change the default as follows :
Current default :
def _report_
return [
'move', 'name', 'date', 'period', 'partner', 'account',
]
New default:
def _report_
return [
'move', 'name', 'date', 'journal', 'period', 'partner', 'account',
]
I'll also update the module documentation so that anyone understands the customisation capabilities without having to read the code.
Regards,
Luc
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Alexis de Lattre
Sent: dinsdag 7 januari 2014 22:39
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls into lp:account-financial-report
Yes, it is available, but it is not displayed by default in the XLS report, cf the fonction _report_
I think that we should add 2 fields in the default report :
- analytic account
- journal code
What do you think ?
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls.
Alexis de Lattre (alexis-via) wrote : | # |
@Luc
I approve your proposal for the new list of default fields !
Frederic Clementi - Camptocamp (frederic-clementi) wrote : | # |
Ok on my side
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) : | # |
Alexis de Lattre (alexis-via) wrote : | # |
@Alexandre :
Thanks for the merge... but it doesn't contain the new list of default fields we decided above in the function _report_
Frederic Clementi - Camptocamp (frederic-clementi) wrote : | # |
@ Alexandre @ Alexis Oups Sorry my mistake. I told Alexandre it was ok.
Frederic Clementi - Camptocamp (frederic-clementi) wrote : | # |
@Luc I agree with the new default list as well
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
Don't worry.
I'll make a new merge with the default fields and documentation update.
Luc
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Alexis de Lattre
Sent: woensdag 8 januari 2014 10:21
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls into lp:account-financial-report
@Alexandre :
Thanks for the merge... but it doesn't contain the new list of default fields we decided above in the function _report_
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls.
Luc De Meyer (Noviat) (luc-demeyer) wrote : | # |
New defaults list available in
https:/
Luc
-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Frederic Clementi - Camptocamp
Sent: woensdag 8 januari 2014 10:51
To: <email address hidden>
Subject: Re: [Merge] lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls into lp:account-financial-report
@Luc I agree with the new default list as well
--
https:/
You are the owner of lp:~luc-demeyer/account-financial-report/7.0-account_move_line_report_xls.
Preview Diff
1 | === added directory 'account_move_line_report_xls' |
2 | === added file 'account_move_line_report_xls/__init__.py' |
3 | --- account_move_line_report_xls/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ account_move_line_report_xls/__init__.py 2013-12-18 18:05:24 +0000 |
5 | @@ -0,0 +1,24 @@ |
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 | +from . import account_move_line |
29 | +from . import report |
30 | |
31 | === added file 'account_move_line_report_xls/__openerp__.py' |
32 | --- account_move_line_report_xls/__openerp__.py 1970-01-01 00:00:00 +0000 |
33 | +++ account_move_line_report_xls/__openerp__.py 2013-12-18 18:05:24 +0000 |
34 | @@ -0,0 +1,46 @@ |
35 | +# -*- encoding: utf-8 -*- |
36 | +############################################################################## |
37 | +# |
38 | +# OpenERP, Open Source Management Solution |
39 | +# |
40 | +# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. |
41 | +# |
42 | +# This program is free software: you can redistribute it and/or modify |
43 | +# it under the terms of the GNU Affero General Public License as |
44 | +# published by the Free Software Foundation, either version 3 of the |
45 | +# License, or (at your option) any later version. |
46 | +# |
47 | +# This program is distributed in the hope that it will be useful, |
48 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
49 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
50 | +# GNU Affero General Public License for more details. |
51 | +# |
52 | +# You should have received a copy of the GNU Affero General Public License |
53 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
54 | +# |
55 | +############################################################################## |
56 | + |
57 | +{ |
58 | + 'name': 'Account Move Line XLS export', |
59 | + 'version': '0.5', |
60 | + 'license': 'AGPL-3', |
61 | + 'author': 'Noviat', |
62 | + 'category' : 'Accounting & Finance', |
63 | + 'description': """ |
64 | + |
65 | +Journal Items Excel Export |
66 | +========================== |
67 | + |
68 | +This module adds a button on the journal items ('account.move.line') list view in order to export the selected lines. |
69 | + |
70 | +If you are installing this module manually, you need also the module 'report_xls', that is located in: |
71 | +https://launchpad.net/openerp-reporting-engines" |
72 | + |
73 | + """, |
74 | + 'depends': ['account', 'report_xls'], |
75 | + 'demo_xml': [], |
76 | + 'init_xml': [], |
77 | + 'update_xml' : [ |
78 | + 'report/move_line_list_xls.xml', |
79 | + ], |
80 | +} |
81 | |
82 | === added file 'account_move_line_report_xls/account_move_line.py' |
83 | --- account_move_line_report_xls/account_move_line.py 1970-01-01 00:00:00 +0000 |
84 | +++ account_move_line_report_xls/account_move_line.py 2013-12-18 18:05:24 +0000 |
85 | @@ -0,0 +1,52 @@ |
86 | +# -*- encoding: utf-8 -*- |
87 | +############################################################################## |
88 | +# |
89 | +# OpenERP, Open Source Management Solution |
90 | +# |
91 | +# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. |
92 | +# |
93 | +# This program is free software: you can redistribute it and/or modify |
94 | +# it under the terms of the GNU Affero General Public License as |
95 | +# published by the Free Software Foundation, either version 3 of the |
96 | +# License, or (at your option) any later version. |
97 | +# |
98 | +# This program is distributed in the hope that it will be useful, |
99 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
100 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
101 | +# GNU Affero General Public License for more details. |
102 | +# |
103 | +# You should have received a copy of the GNU Affero General Public License |
104 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
105 | +# |
106 | +############################################################################## |
107 | + |
108 | +from openerp.osv import orm |
109 | +from openerp.addons.report_xls.utils import rowcol_to_cell, _render |
110 | +from openerp.tools.translate import _ |
111 | + |
112 | +class account_move_line(orm.Model): |
113 | + _inherit = 'account.move.line' |
114 | + |
115 | + # override list in custom module to add/drop columns or change order |
116 | + def _report_xls_fields(self, cr, uid, context=None): |
117 | + return [ |
118 | + 'move', 'name', 'date', 'period', 'partner', 'account', |
119 | + 'date_maturity', 'debit', 'credit', 'balance', 'reconcile', 'reconcile_partial', |
120 | + #'amount_currency', 'currency_name', |
121 | + ] |
122 | + |
123 | + # Change/Add Template entries |
124 | + def _report_xls_template(self, cr, uid, context=None): |
125 | + """ |
126 | + Template updates, e.g. |
127 | + |
128 | + my_change = { |
129 | + 'move':{ |
130 | + 'header': [1, 20, 'text', _('My Move Title')], |
131 | + 'lines': [1, 0, 'text', _render("line.move_id.name or ''")], |
132 | + 'totals': [1, 0, 'text', None]}, |
133 | + } |
134 | + return my_change |
135 | + """ |
136 | + return {} |
137 | + |
138 | |
139 | === added directory 'account_move_line_report_xls/i18n' |
140 | === added file 'account_move_line_report_xls/i18n/fr.po' |
141 | --- account_move_line_report_xls/i18n/fr.po 1970-01-01 00:00:00 +0000 |
142 | +++ account_move_line_report_xls/i18n/fr.po 2013-12-18 18:05:24 +0000 |
143 | @@ -0,0 +1,111 @@ |
144 | +# French translation of OpenERP Server 6.1. |
145 | +# This file contains the translation of the following modules: |
146 | +# * account_move_line_report_xls |
147 | +# |
148 | +msgid "" |
149 | +msgstr "" |
150 | +"Project-Id-Version: OpenERP Server 6.1\n" |
151 | +"Report-Msgid-Bugs-To: support@noviat.be\n" |
152 | +"POT-Creation-Date: 2013-11-23 16:11:12.706000\n" |
153 | +"PO-Revision-Date: 2013-11-23 16:11:12.706000\n" |
154 | +"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" |
155 | +"Language-Team: \n" |
156 | +"MIME-Version: 1.0\n" |
157 | +"Content-Type: text/plain; charset=UTF-8\n" |
158 | +"Content-Transfer-Encoding: 8bit\n" |
159 | + |
160 | +#. module: account_move_line_report_xls |
161 | +#: report:move.line.list.xls:0 |
162 | +msgid "Journal Items" |
163 | +msgstr "Écritures comptables" |
164 | + |
165 | +#. module: account_move_line_report_xls |
166 | +#: report:move.line.list.xls:0 |
167 | +msgid "Entry" |
168 | +msgstr "Écriture" |
169 | + |
170 | +#. module: account_move_line_report_xls |
171 | +#: report:move.line.list.xls:0 |
172 | +msgid "Name" |
173 | +msgstr "Nom" |
174 | + |
175 | +#. module: account_move_line_report_xls |
176 | +#: report:move.line.list.xls:0 |
177 | +msgid "Reference" |
178 | +msgstr "Référence" |
179 | + |
180 | +#. module: account_move_line_report_xls |
181 | +#: report:move.line.list.xls:0 |
182 | +msgid "Effective Date" |
183 | +msgstr "Date" |
184 | + |
185 | +#. module: account_move_line_report_xls |
186 | +#: report:move.line.list.xls:0 |
187 | +msgid "Period" |
188 | +msgstr "Période" |
189 | + |
190 | +#. module: account_move_line_report_xls |
191 | +#: report:move.line.list.xls:0 |
192 | +msgid "Partner" |
193 | +msgstr "Partenaire" |
194 | + |
195 | +#. module: account_move_line_report_xls |
196 | +#: report:move.line.list.xls:0 |
197 | +msgid "Partner Reference" |
198 | +msgstr "Réf. Partenaire" |
199 | + |
200 | +#. module: account_move_line_report_xls |
201 | +#: report:move.line.list.xls:0 |
202 | +msgid "Account" |
203 | +msgstr "Compte" |
204 | + |
205 | +#. module: account_move_line_report_xls |
206 | +#: report:move.line.list.xls:0 |
207 | +msgid "Maturity Date" |
208 | +msgstr "Date d'échéance" |
209 | + |
210 | +#. module: account_move_line_report_xls |
211 | +#: report:move.line.list.xls:0 |
212 | +msgid "Debit" |
213 | +msgstr "Débit" |
214 | + |
215 | +#. module: account_move_line_report_xls |
216 | +#: report:move.line.list.xls:0 |
217 | +msgid "Credit" |
218 | +msgstr "Crédit" |
219 | + |
220 | +#. module: account_move_line_report_xls |
221 | +#: report:move.line.list.xls:0 |
222 | +msgid "Balance" |
223 | +msgstr "Solde" |
224 | + |
225 | +#. module: account_move_line_report_xls |
226 | +#: report:move.line.list.xls:0 |
227 | +msgid "Rec." |
228 | +msgstr "Let." |
229 | + |
230 | +#. module: account_move_line_report_xls |
231 | +#: report:move.line.list.xls:0 |
232 | +msgid "Part. Rec." |
233 | +msgstr "Let. Part." |
234 | + |
235 | +#. module: account_move_line_report_xls |
236 | +#: report:move.line.list.xls:0 |
237 | +msgid "Tax Code" |
238 | +msgstr "Case TVA" |
239 | + |
240 | +#. module: account_move_line_report_xls |
241 | +#: report:move.line.list.xls:0 |
242 | +msgid "Tax/Base Amount" |
243 | +msgstr "Montant TVA/Base" |
244 | + |
245 | +#. module: account_move_line_report_xls |
246 | +#: report:move.line.list.xls:0 |
247 | +msgid "Am. Currency" |
248 | +msgstr "Montant devise" |
249 | + |
250 | +#. module: account_move_line_report_xls |
251 | +#: report:move.line.list.xls:0 |
252 | +msgid "Curr." |
253 | +msgstr "Dev." |
254 | + |
255 | |
256 | === added file 'account_move_line_report_xls/i18n/nl.po' |
257 | --- account_move_line_report_xls/i18n/nl.po 1970-01-01 00:00:00 +0000 |
258 | +++ account_move_line_report_xls/i18n/nl.po 2013-12-18 18:05:24 +0000 |
259 | @@ -0,0 +1,111 @@ |
260 | +# Dutch translation of OpenERP Server 6.1. |
261 | +# This file contains the translation of the following modules: |
262 | +# * account_move_line_report_xls |
263 | +# |
264 | +msgid "" |
265 | +msgstr "" |
266 | +"Project-Id-Version: OpenERP Server 6.1\n" |
267 | +"Report-Msgid-Bugs-To: support@noviat.be\n" |
268 | +"POT-Creation-Date: 2013-11-23 16:11:12.702000\n" |
269 | +"PO-Revision-Date: 2013-11-23 16:11:12.702000\n" |
270 | +"Last-Translator: Luc De Meyer (Noviat nv/sa)\n" |
271 | +"Language-Team: \n" |
272 | +"MIME-Version: 1.0\n" |
273 | +"Content-Type: text/plain; charset=UTF-8\n" |
274 | +"Content-Transfer-Encoding: 8bit\n" |
275 | + |
276 | +#. module: account_move_line_report_xls |
277 | +#: report:move.line.list.xls:0 |
278 | +msgid "Journal Items" |
279 | +msgstr "Boekingsregels" |
280 | + |
281 | +#. module: account_move_line_report_xls |
282 | +#: report:move.line.list.xls:0 |
283 | +msgid "Entry" |
284 | +msgstr "Boeking" |
285 | + |
286 | +#. module: account_move_line_report_xls |
287 | +#: report:move.line.list.xls:0 |
288 | +msgid "Name" |
289 | +msgstr "Naam" |
290 | + |
291 | +#. module: account_move_line_report_xls |
292 | +#: report:move.line.list.xls:0 |
293 | +msgid "Reference" |
294 | +msgstr "Referentie" |
295 | + |
296 | +#. module: account_move_line_report_xls |
297 | +#: report:move.line.list.xls:0 |
298 | +msgid "Effective Date" |
299 | +msgstr "Datum" |
300 | + |
301 | +#. module: account_move_line_report_xls |
302 | +#: report:move.line.list.xls:0 |
303 | +msgid "Period" |
304 | +msgstr "Periode" |
305 | + |
306 | +#. module: account_move_line_report_xls |
307 | +#: report:move.line.list.xls:0 |
308 | +msgid "Partner" |
309 | +msgstr "Partner" |
310 | + |
311 | +#. module: account_move_line_report_xls |
312 | +#: report:move.line.list.xls:0 |
313 | +msgid "Partner Reference" |
314 | +msgstr "Ref. Partner" |
315 | + |
316 | +#. module: account_move_line_report_xls |
317 | +#: report:move.line.list.xls:0 |
318 | +msgid "Account" |
319 | +msgstr "Rekening" |
320 | + |
321 | +#. module: account_move_line_report_xls |
322 | +#: report:move.line.list.xls:0 |
323 | +msgid "Maturity Date" |
324 | +msgstr "Vervaldatum" |
325 | + |
326 | +#. module: account_move_line_report_xls |
327 | +#: report:move.line.list.xls:0 |
328 | +msgid "Debit" |
329 | +msgstr "Debet" |
330 | + |
331 | +#. module: account_move_line_report_xls |
332 | +#: report:move.line.list.xls:0 |
333 | +msgid "Credit" |
334 | +msgstr "Credit" |
335 | + |
336 | +#. module: account_move_line_report_xls |
337 | +#: report:move.line.list.xls:0 |
338 | +msgid "Balance" |
339 | +msgstr "Saldo" |
340 | + |
341 | +#. module: account_move_line_report_xls |
342 | +#: report:move.line.list.xls:0 |
343 | +msgid "Rec." |
344 | +msgstr "Rec." |
345 | + |
346 | +#. module: account_move_line_report_xls |
347 | +#: report:move.line.list.xls:0 |
348 | +msgid "Part. Rec." |
349 | +msgstr "Rec. Part." |
350 | + |
351 | +#. module: account_move_line_report_xls |
352 | +#: report:move.line.list.xls:0 |
353 | +msgid "Tax Code" |
354 | +msgstr "BTW vak" |
355 | + |
356 | +#. module: account_move_line_report_xls |
357 | +#: report:move.line.list.xls:0 |
358 | +msgid "Tax/Base Amount" |
359 | +msgstr "Bedrag BTW/Mvh" |
360 | + |
361 | +#. module: account_move_line_report_xls |
362 | +#: report:move.line.list.xls:0 |
363 | +msgid "Am. Currency" |
364 | +msgstr "Bedrag valuta" |
365 | + |
366 | +#. module: account_move_line_report_xls |
367 | +#: report:move.line.list.xls:0 |
368 | +msgid "Curr." |
369 | +msgstr "Val." |
370 | + |
371 | |
372 | === added directory 'account_move_line_report_xls/report' |
373 | === added file 'account_move_line_report_xls/report/__init__.py' |
374 | --- account_move_line_report_xls/report/__init__.py 1970-01-01 00:00:00 +0000 |
375 | +++ account_move_line_report_xls/report/__init__.py 2013-12-18 18:05:24 +0000 |
376 | @@ -0,0 +1,23 @@ |
377 | +# -*- encoding: utf-8 -*- |
378 | +############################################################################## |
379 | +# |
380 | +# OpenERP, Open Source Management Solution |
381 | +# |
382 | +# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. |
383 | +# |
384 | +# This program is free software: you can redistribute it and/or modify |
385 | +# it under the terms of the GNU Affero General Public License as |
386 | +# published by the Free Software Foundation, either version 3 of the |
387 | +# License, or (at your option) any later version. |
388 | +# |
389 | +# This program is distributed in the hope that it will be useful, |
390 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
391 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
392 | +# GNU Affero General Public License for more details. |
393 | +# |
394 | +# You should have received a copy of the GNU Affero General Public License |
395 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
396 | +# |
397 | +############################################################################## |
398 | + |
399 | +from . import move_line_list_xls |
400 | |
401 | === added file 'account_move_line_report_xls/report/move_line_list_xls.py' |
402 | --- account_move_line_report_xls/report/move_line_list_xls.py 1970-01-01 00:00:00 +0000 |
403 | +++ account_move_line_report_xls/report/move_line_list_xls.py 2013-12-18 18:05:24 +0000 |
404 | @@ -0,0 +1,240 @@ |
405 | +# -*- encoding: utf-8 -*- |
406 | +############################################################################## |
407 | +# |
408 | +# OpenERP, Open Source Management Solution |
409 | +# |
410 | +# Copyright (c) 2013 Noviat nv/sa (www.noviat.com). All rights reserved. |
411 | +# |
412 | +# This program is free software: you can redistribute it and/or modify |
413 | +# it under the terms of the GNU Affero General Public License as |
414 | +# published by the Free Software Foundation, either version 3 of the |
415 | +# License, or (at your option) any later version. |
416 | +# |
417 | +# This program is distributed in the hope that it will be useful, |
418 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
419 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
420 | +# GNU Affero General Public License for more details. |
421 | +# |
422 | +# You should have received a copy of the GNU Affero General Public License |
423 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
424 | +# |
425 | +############################################################################## |
426 | + |
427 | +import xlwt |
428 | +import time |
429 | +from datetime import datetime |
430 | +from openerp.osv import orm |
431 | +from openerp.report import report_sxw |
432 | +from openerp.addons.report_xls.report_xls import report_xls |
433 | +from openerp.addons.report_xls.utils import rowcol_to_cell, _render |
434 | +from openerp.tools.translate import translate, _ |
435 | +from openerp import pooler |
436 | +import logging |
437 | +_logger = logging.getLogger(__name__) |
438 | + |
439 | +_ir_translation_name = 'move.line.list.xls' |
440 | + |
441 | +class move_line_xls_parser(report_sxw.rml_parse): |
442 | + |
443 | + def __init__(self, cr, uid, name, context): |
444 | + super(move_line_xls_parser, self).__init__(cr, uid, name, context=context) |
445 | + move_obj = self.pool.get('account.move.line') |
446 | + self.context = context |
447 | + wanted_list = move_obj._report_xls_fields(cr, uid, context) |
448 | + template_changes = move_obj._report_xls_template(cr, uid, context) |
449 | + self.localcontext.update({ |
450 | + 'datetime': datetime, |
451 | + 'wanted_list': wanted_list, |
452 | + 'template_changes': template_changes, |
453 | + '_': self._, |
454 | + }) |
455 | + |
456 | + def _(self, src): |
457 | + lang = self.context.get('lang', 'en_US') |
458 | + return translate(self.cr, _ir_translation_name, 'report', lang, src) or src |
459 | + |
460 | +class move_line_xls(report_xls): |
461 | + |
462 | + def __init__(self, name, table, rml=False, parser=False, header=True, store=False): |
463 | + super(move_line_xls, self).__init__(name, table, rml, parser, header, store) |
464 | + |
465 | + # Cell Styles |
466 | + _xs = self.xls_styles |
467 | + # header |
468 | + rh_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] |
469 | + self.rh_cell_style = xlwt.easyxf(rh_cell_format) |
470 | + self.rh_cell_style_center = xlwt.easyxf(rh_cell_format + _xs['center']) |
471 | + self.rh_cell_style_right = xlwt.easyxf(rh_cell_format + _xs['right']) |
472 | + # lines |
473 | + aml_cell_format = _xs['borders_all'] |
474 | + self.aml_cell_style = xlwt.easyxf(aml_cell_format) |
475 | + self.aml_cell_style_center = xlwt.easyxf(aml_cell_format + _xs['center']) |
476 | + self.aml_cell_style_date = xlwt.easyxf(aml_cell_format + _xs['left'], num_format_str = report_xls.date_format) |
477 | + self.aml_cell_style_decimal = xlwt.easyxf(aml_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) |
478 | + # totals |
479 | + rt_cell_format = _xs['bold'] + _xs['fill'] + _xs['borders_all'] |
480 | + self.rt_cell_style = xlwt.easyxf(rt_cell_format) |
481 | + self.rt_cell_style_right = xlwt.easyxf(rt_cell_format + _xs['right']) |
482 | + self.rt_cell_style_decimal = xlwt.easyxf(rt_cell_format + _xs['right'], num_format_str = report_xls.decimal_format) |
483 | + |
484 | + # XLS Template |
485 | + self.col_specs_template = { |
486 | + 'move':{ |
487 | + 'header': [1, 20, 'text', _render("_('Entry')")], |
488 | + 'lines': [1, 0, 'text', _render("line.move_id.name or ''")], |
489 | + 'totals': [1, 0, 'text', None]}, |
490 | + 'name':{ |
491 | + 'header': [1, 42, 'text', _render("_('Name')")], |
492 | + 'lines': [1, 0, 'text', _render("line.name or ''")], |
493 | + 'totals': [1, 0, 'text', None]}, |
494 | + 'ref':{ |
495 | + 'header': [1, 42, 'text', _render("_('Reference')")], |
496 | + 'lines': [1, 0, 'text', _render("line.ref or ''")], |
497 | + 'totals': [1, 0, 'text', None]}, |
498 | + 'date':{ |
499 | + 'header': [1, 13, 'text', _render("_('Effective Date')")], |
500 | + 'lines': [1, 0, 'date', _render("datetime.strptime(line.date,'%Y-%m-%d')"), None, self.aml_cell_style_date], |
501 | + 'totals': [1, 0, 'text', None]}, |
502 | + 'period':{ |
503 | + 'header': [1, 12, 'text', _render("_('Period')")], |
504 | + 'lines': [1, 0, 'text', _render("line.period_id.code or line.period_id.name")], |
505 | + 'totals': [1, 0, 'text', None]}, |
506 | + 'partner':{ |
507 | + 'header': [1, 36, 'text', _render("_('Partner')")], |
508 | + 'lines': [1, 0, 'text', _render("line.partner_id and line.partner_id.name or ''")], |
509 | + 'totals': [1, 0, 'text', None]}, |
510 | + 'partner_ref':{ |
511 | + 'header': [1, 36, 'text', _render("_('Partner Reference')")], |
512 | + 'lines': [1, 0, 'text', _render("line.partner_id and line.partner_id.ref or ''")], |
513 | + 'totals': [1, 0, 'text', None]}, |
514 | + 'account':{ |
515 | + 'header': [1, 12, 'text', _render("_('Account')")], |
516 | + 'lines': [1, 0, 'text', _render("line.account_id.code")], |
517 | + 'totals': [1, 0, 'text', None]}, |
518 | + 'date_maturity':{ |
519 | + 'header': [1, 13, 'text', _render("_('Maturity Date')")], |
520 | + 'lines': [1, 0, _render("line.date_maturity.val and 'date' or 'text'"), |
521 | + _render("line.date_maturity.val and datetime.strptime(line.date_maturity,'%Y-%m-%d') or None"), |
522 | + None, self.aml_cell_style_date], |
523 | + 'totals': [1, 0, 'text', None]}, |
524 | + 'debit':{ |
525 | + 'header': [1, 18, 'text', _render("_('Debit')"), None, self.rh_cell_style_right], |
526 | + 'lines': [1, 0, 'number', _render("line.debit"), None, self.aml_cell_style_decimal], |
527 | + 'totals': [1, 0, 'number', None, _render("debit_formula"), self.rt_cell_style_decimal]}, |
528 | + 'credit':{ |
529 | + 'header': [1, 18, 'text', _render("_('Credit')"), None, self.rh_cell_style_right], |
530 | + 'lines': [1, 0, 'number', _render("line.credit"), None, self.aml_cell_style_decimal], |
531 | + 'totals': [1, 0, 'number', None, _render("credit_formula"), self.rt_cell_style_decimal]}, |
532 | + 'balance':{ |
533 | + 'header': [1, 18, 'text', _render("_('Balance')"), None, self.rh_cell_style_right], |
534 | + 'lines': [1, 0, 'number', None, _render("bal_formula"), self.aml_cell_style_decimal], |
535 | + 'totals': [1, 0, 'number', None, _render("bal_formula"), self.rt_cell_style_decimal]}, |
536 | + 'reconcile':{ |
537 | + 'header': [1, 12, 'text', _render("_('Rec.')"), None, self.rh_cell_style_center], |
538 | + 'lines': [1, 0, 'text', _render("line.reconcile_id.name or ''"), None, self.aml_cell_style_center], |
539 | + 'totals': [1, 0, 'text', None]}, |
540 | + 'reconcile_partial':{ |
541 | + 'header': [1, 12, 'text', _render("_('Part. Rec.')"), None, self.rh_cell_style_center], |
542 | + 'lines': [1, 0, 'text', _render("line.reconcile_partial_id.name or ''"), None, self.aml_cell_style_center], |
543 | + 'totals': [1, 0, 'text', None]}, |
544 | + 'tax_code':{ |
545 | + 'header': [1, 12, 'text', _render("_('Tax Code')"), None, self.rh_cell_style_center], |
546 | + 'lines': [1, 0, 'text', _render("line.tax_code_id.code or ''"), None, self.aml_cell_style_center], |
547 | + 'totals': [1, 0, 'text', None]}, |
548 | + 'tax_amount':{ |
549 | + 'header': [1, 18, 'text', _render("_('Tax/Base Amount')"), None, self.rh_cell_style_right], |
550 | + 'lines': [1, 0, 'number', _render("line.tax_amount"), None, self.aml_cell_style_decimal], |
551 | + 'totals': [1, 0, 'text', None]}, |
552 | + 'amount_currency':{ |
553 | + 'header': [1, 18, 'text', _render("_('Am. Currency')"), None, self.rh_cell_style_right], |
554 | + 'lines': [1, 0, _render("line.amount_currency and 'number' or 'text'"), |
555 | + _render("line.amount_currency or None"), |
556 | + None, self.aml_cell_style_decimal], |
557 | + 'totals': [1, 0, 'text', None]}, |
558 | + 'currency_name':{ |
559 | + 'header': [1, 6, 'text', _render("_('Curr.')"), None, self.rh_cell_style_center], |
560 | + 'lines': [1, 0, 'text', _render("line.currency_id and line.currency_id.name or ''"), None, self.aml_cell_style_center], |
561 | + 'totals': [1, 0, 'text', None]}, |
562 | + 'journal': { |
563 | + 'header': [1, 6, 'text', _('Journal')], |
564 | + 'lines': [1, 0, 'text', _render("line.journal_id.code or ''")], |
565 | + 'totals': [1, 0, 'text', None]}, |
566 | + 'company_currency': { |
567 | + 'header': [1, 6, 'text', _('Company currency')], |
568 | + 'lines': [1, 0, 'text', _render("line.company_id.currency_id.name or ''")], |
569 | + 'totals': [1, 0, 'text', None]}, |
570 | + 'analytic_account': { |
571 | + 'header': [1, 6, 'text', _('Analytic Account')], |
572 | + 'lines': [1, 0, 'text', _render("line.analytic_account_id.code or ''")], |
573 | + 'totals': [1, 0, 'text', None]}, |
574 | + } |
575 | + |
576 | + def generate_xls_report(self, _p, _xs, data, objects, wb): |
577 | + |
578 | + wanted_list = _p.wanted_list |
579 | + self.col_specs_template.update(_p.template_changes) |
580 | + _ = _p._ |
581 | + |
582 | + debit_pos = 'debit' in wanted_list and wanted_list.index('debit') |
583 | + credit_pos = 'credit' in wanted_list and wanted_list.index('credit') |
584 | + if not (credit_pos and debit_pos) and 'balance' in wanted_list: |
585 | + raise orm.except_orm(_('Customisation Error!'), |
586 | + _("The 'Balance' field is a calculated XLS field requiring the presence of the 'Debit' and 'Credit' fields !")) |
587 | + |
588 | + #report_name = objects[0]._description or objects[0]._name |
589 | + report_name = _("Journal Items") |
590 | + ws = wb.add_sheet(report_name[:31]) |
591 | + ws.panes_frozen = True |
592 | + ws.remove_splits = True |
593 | + ws.portrait = 0 # Landscape |
594 | + ws.fit_width_to_pages = 1 |
595 | + row_pos = 0 |
596 | + |
597 | + # set print header/footer |
598 | + ws.header_str = self.xls_headers['standard'] |
599 | + ws.footer_str = self.xls_footers['standard'] |
600 | + |
601 | + # Title |
602 | + cell_style = xlwt.easyxf(_xs['xls_title']) |
603 | + c_specs = [ |
604 | + ('report_name', 1, 0, 'text', report_name), |
605 | + ] |
606 | + row_data = self.xls_row_template(c_specs, ['report_name']) |
607 | + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style) |
608 | + row_pos += 1 |
609 | + |
610 | + # Column headers |
611 | + c_specs = map(lambda x: self.render(x, self.col_specs_template, 'header', render_space={'_': _p._}), wanted_list) |
612 | + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
613 | + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rh_cell_style, set_column_size=True) |
614 | + ws.set_horz_split_pos(row_pos) |
615 | + |
616 | + # account move lines |
617 | + for line in objects: |
618 | + debit_cell = rowcol_to_cell(row_pos, debit_pos) |
619 | + credit_cell = rowcol_to_cell(row_pos, credit_pos) |
620 | + bal_formula = debit_cell + '-' + credit_cell |
621 | + c_specs = map(lambda x: self.render(x, self.col_specs_template, 'lines'), wanted_list) |
622 | + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
623 | + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.aml_cell_style) |
624 | + |
625 | + # Totals |
626 | + aml_cnt = len(objects) |
627 | + debit_start = rowcol_to_cell(row_pos - aml_cnt, debit_pos) |
628 | + debit_stop = rowcol_to_cell(row_pos - 1, debit_pos) |
629 | + debit_formula = 'SUM(%s:%s)' %(debit_start, debit_stop) |
630 | + credit_start = rowcol_to_cell(row_pos - aml_cnt, credit_pos) |
631 | + credit_stop = rowcol_to_cell(row_pos - 1, credit_pos) |
632 | + credit_formula = 'SUM(%s:%s)' %(credit_start, credit_stop) |
633 | + debit_cell = rowcol_to_cell(row_pos, debit_pos) |
634 | + credit_cell = rowcol_to_cell(row_pos, credit_pos) |
635 | + bal_formula = debit_cell + '-' + credit_cell |
636 | + c_specs = map(lambda x: self.render(x, self.col_specs_template, 'totals'), wanted_list) |
637 | + row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs]) |
638 | + row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=self.rt_cell_style_right) |
639 | + |
640 | +move_line_xls('report.move.line.list.xls', |
641 | + 'account.move.line', |
642 | + parser=move_line_xls_parser) |
643 | + |
644 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
645 | \ No newline at end of file |
646 | |
647 | === added file 'account_move_line_report_xls/report/move_line_list_xls.xml' |
648 | --- account_move_line_report_xls/report/move_line_list_xls.xml 1970-01-01 00:00:00 +0000 |
649 | +++ account_move_line_report_xls/report/move_line_list_xls.xml 2013-12-18 18:05:24 +0000 |
650 | @@ -0,0 +1,22 @@ |
651 | +<?xml version="1.0" encoding="utf-8"?> |
652 | +<openerp> |
653 | + <data> |
654 | + |
655 | + <record id="action_move_line_list_xls" model="ir.actions.report.xml"> |
656 | + <field name="name">Export Selected Lines</field> |
657 | + <field name="model">account.move.line</field> |
658 | + <field name="type">ir.actions.report.xml</field> |
659 | + <field name="report_name">move.line.list.xls</field> |
660 | + <field name="report_type">xls</field> |
661 | + <field name="auto" eval="False"/> |
662 | + </record> |
663 | + |
664 | + <record model="ir.values" id="action_move_line_list_xls_values"> |
665 | + <field name="name">Export Selected Lines</field> |
666 | + <field name="key2">client_action_multi</field> |
667 | + <field name="value" eval="'ir.actions.report.xml,' +str(ref('action_move_line_list_xls'))" /> |
668 | + <field name="model">account.move.line</field> |
669 | + </record> |
670 | + |
671 | + </data> |
672 | +</openerp> |
673 | |
674 | === added directory 'account_move_line_report_xls/static' |
675 | === added directory 'account_move_line_report_xls/static/src' |
676 | === added directory 'account_move_line_report_xls/static/src/img' |
677 | === added file 'account_move_line_report_xls/static/src/img/icon.png' |
678 | Binary files account_move_line_report_xls/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and account_move_line_report_xls/static/src/img/icon.png 2013-12-18 18:05:24 +0000 differ |
Could you take the time to bring this to the 7.0 community addons coding conventions. This includes:
* not using the shortcut imports (things in the openerp namespace need to be imported from openerp)
* using the from . import xxx for relative imports (typically in __init__.py files)
* using orm.Model and orm.TransientModel as base class rather than osv.osv and osv.osv_memory
* not instanciating the model classes
* following PEP8 for spacing, line wrapping, etc.
Nice to have would be a couple of automated tests exercising the code.