Merge lp:~rafael-valle-z/openerp-spain/openerp-spain-xls-reports into lp:~openerp-spain-team/openerp-spain/6.1
- openerp-spain-xls-reports
- Merge into 6.1
Status: | Merged |
---|---|
Merged at revision: | 393 |
Proposed branch: | lp:~rafael-valle-z/openerp-spain/openerp-spain-xls-reports |
Merge into: | lp:~openerp-spain-team/openerp-spain/6.1 |
Diff against target: |
3511 lines (+3378/-0) 24 files modified
account_financial_report_web/__init__.py (+25/-0) account_financial_report_web/__openerp__.py (+34/-0) account_financial_report_web/account_report_report.xml (+17/-0) account_financial_report_web/account_report_wizard.xml (+115/-0) account_financial_report_web/i18n/es.po (+367/-0) account_financial_report_web/report/__init__.py (+25/-0) account_financial_report_web/report/account_balance.py (+314/-0) account_financial_report_web/report/general_ledger.py (+412/-0) account_financial_report_web/report/general_ledger_landscape.py (+413/-0) account_financial_report_web/report/rml_parse.py (+172/-0) account_financial_report_web/wizard/__init__.py (+23/-0) account_financial_report_web/wizard/wizard_account_balance_report.py (+244/-0) report_cumulative_general_ledger_xls/__init__.py (+29/-0) report_cumulative_general_ledger_xls/__openerp__.py (+38/-0) report_cumulative_general_ledger_xls/i18n/es.po (+72/-0) report_cumulative_general_ledger_xls/wizard/__init__.py (+27/-0) report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py (+434/-0) report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger_xls_view.xml (+26/-0) report_general_ledger_xls/__init__.py (+29/-0) report_general_ledger_xls/__openerp__.py (+39/-0) report_general_ledger_xls/i18n/es.po (+63/-0) report_general_ledger_xls/wizard/__init__.py (+27/-0) report_general_ledger_xls/wizard/account_report_general_ledger.py (+407/-0) report_general_ledger_xls/wizard/account_report_ledger_xls_view.xml (+26/-0) |
To merge this branch: | bzr merge lp:~rafael-valle-z/openerp-spain/openerp-spain-xls-reports |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ignacio Ibeas (www.acysos.com) | Approve | ||
Alberto Garcia (Factor Libre) | Approve | ||
Pedro Manuel Baeza | Pending | ||
Review via email: mp+203718@code.launchpad.net |
Commit message
Description of the change
Añadidos 3 módulos:
- account_
- report_
- report_
Probado en la versión 6.1
Alberto Garcia (Factor Libre) (agarcia-flibre) wrote : | # |
Ignacio Ibeas (www.acysos.com) (ignacio-acysos) : | # |
Ignacio Ibeas (www.acysos.com) (ignacio-acysos) wrote : | # |
Probados y funcionan perfectamente.
Tenéis pensado o estáis haciendo lo mismo para Sumas y Saldos y Balance de situación?
Si no lo estáis haciendo, me puedo encargar del primero a partir del desarrollo que ya habéis hecho.
Saludos
Alberto Garcia (Factor Libre) (agarcia-flibre) wrote : | # |
Buenas. Pensaba que ya lo habíamos hecho el merge. De momento no hemos hecho para los que comentas. Pero sería lo mas idoneo.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Tened en cuenta que para la v7 en el repositorio account-
Un saludo.
Ignacio Ibeas (www.acysos.com) (ignacio-acysos) wrote : | # |
Los módulos que indica Pedro, también están en la 6.1 y son más completos, tiene sumas y saldos y informes de diarios. Para la 6.0 no hay nada.
Saludos
Preview Diff
1 | === added directory 'account_financial_report_web' |
2 | === added file 'account_financial_report_web/__init__.py' |
3 | --- account_financial_report_web/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ account_financial_report_web/__init__.py 2014-01-29 11:51:34 +0000 |
5 | @@ -0,0 +1,25 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# OpenERP, Open Source Management Solution |
10 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
11 | +# |
12 | +# This program is free software: you can redistribute it and/or modify |
13 | +# it under the terms of the GNU Affero General Public License as |
14 | +# published by the Free Software Foundation, either version 3 of the |
15 | +# License, or (at your option) any later version. |
16 | +# |
17 | +# This program is distributed in the hope that it will be useful, |
18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | +# GNU Affero General Public License for more details. |
21 | +# |
22 | +# You should have received a copy of the GNU Affero General Public License |
23 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
24 | +# |
25 | +############################################################################## |
26 | + |
27 | +import wizard |
28 | +import report |
29 | + |
30 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
31 | |
32 | === added file 'account_financial_report_web/__openerp__.py' |
33 | --- account_financial_report_web/__openerp__.py 1970-01-01 00:00:00 +0000 |
34 | +++ account_financial_report_web/__openerp__.py 2014-01-29 11:51:34 +0000 |
35 | @@ -0,0 +1,34 @@ |
36 | +# -*- coding: utf-8 -*- |
37 | +############################################################################## |
38 | +# |
39 | +# OpenERP, Open Source Management Solution |
40 | +# Copyright (C) 2013 Factor Libre. |
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 Financial Report Web", |
59 | + "version": "0.1", |
60 | + "author": "Factor Libre", |
61 | + "category": "Others", |
62 | + "website": "http://www.factorlibre.com", |
63 | + "description": "Update Account Financial Report (Factor Libre Project)", |
64 | + "depends": ["base", "account_financial_report"], |
65 | + "init_xml": [], |
66 | + "update_xml": ["account_report_report.xml","account_report_wizard.xml",], |
67 | + "active": False, |
68 | + "installable": True, |
69 | +} |
70 | |
71 | === added file 'account_financial_report_web/account_report_report.xml' |
72 | --- account_financial_report_web/account_report_report.xml 1970-01-01 00:00:00 +0000 |
73 | +++ account_financial_report_web/account_report_report.xml 2014-01-29 11:51:34 +0000 |
74 | @@ -0,0 +1,17 @@ |
75 | +<?xml version="1.0" encoding="UTF-8"?> |
76 | +<openerp> |
77 | + <data > |
78 | + |
79 | + # Report full account balance |
80 | + <report |
81 | + id="account_balance_full3" |
82 | + string="**Full account balance" |
83 | + model="account.account" |
84 | + name="account.balance.full3" |
85 | + rml="fl_account_financial_report/report/account_balance_full.rml" |
86 | + header="False" |
87 | + auto="False" |
88 | + menu="False"/> |
89 | + |
90 | + </data> |
91 | +</openerp> |
92 | |
93 | === added file 'account_financial_report_web/account_report_wizard.xml' |
94 | --- account_financial_report_web/account_report_wizard.xml 1970-01-01 00:00:00 +0000 |
95 | +++ account_financial_report_web/account_report_wizard.xml 2014-01-29 11:51:34 +0000 |
96 | @@ -0,0 +1,115 @@ |
97 | +<?xml version="1.0" encoding="UTF-8"?> |
98 | +<openerp> |
99 | + <data > |
100 | + <record id="account_balance_full_report_form3" model="ir.ui.view"> |
101 | + <field name="name">account.balance.full.report.form3</field> |
102 | + <field name="model">fl.account.balance.full.report</field> |
103 | + <field name="type">form</field> |
104 | + <field name="arch" type="xml"> |
105 | + <form string="Full Account Balance2"> |
106 | + <field name="company_id" on_change="onchange_company_id(company_id)"/> |
107 | + <newline/> |
108 | + <group colspan="4"> |
109 | + <separator string="Accounts to include" colspan="4"/> |
110 | + <field name="account_list" nolabel="1" colspan="4" domain="[('company_id','=',company_id)]"/> |
111 | + <field name="display_account" required="True"/> |
112 | + <field name="display_account_level" required="True" /> |
113 | + </group> |
114 | + <group colspan="4"> |
115 | + <separator string="Period" colspan="4"/> |
116 | + <field name="fiscalyear"/> |
117 | + <newline/> |
118 | + <field name="state" required="True"/> |
119 | + <newline/> |
120 | + <group attrs="{'invisible':[('state','=','none')]}" colspan="4"> |
121 | + <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4"> |
122 | + <separator string="Date Filter" colspan="4"/> |
123 | + <field name="date_from"/> |
124 | + <field name="date_to"/> |
125 | + </group> |
126 | + <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4"> |
127 | + <separator string="Filter on Periods" colspan="4"/> |
128 | + <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/> |
129 | + </group> |
130 | + </group> |
131 | + </group> |
132 | + <button special="cancel" string="Cancel" icon="gtk-cancel"/> |
133 | + <button name="print_report" string="Get Balance" type="object" icon="gtk-ok"/> |
134 | + </form> |
135 | + </field> |
136 | + </record> |
137 | + |
138 | + <record id="action_balance_full_xml_report3" model="ir.actions.act_window"> |
139 | + <field name="name">**Full account balance3</field> |
140 | + <field name="res_model">fl.account.balance.full.report</field> |
141 | + <field name="view_type">form</field> |
142 | + <field name="view_mode">form</field> |
143 | + <field name="view_id" ref="account_balance_full_report_form3"/> |
144 | + <field name="target">new</field> |
145 | + </record> |
146 | + <menuitem id="account_financial_report.menu_account_balance_full_report" action="action_balance_full_xml_report3" |
147 | + parent="account.menu_finance_generic_reporting" icon="STOCK_PRINT" |
148 | + name="**Full account balance" sequence="100"/> |
149 | + |
150 | + <record id="account_general_ledger_cumulative_report_form2" model="ir.ui.view"> |
151 | + <field name="name">account.general.ledger.cumulative.report.form2</field> |
152 | + <field name="model">fl.account.general.ledger.cumulative.report</field> |
153 | + <field name="type">form</field> |
154 | + <field name="arch" type="xml"> |
155 | + <form string="General ledger"> |
156 | + <field name="states" invisible="1"/> |
157 | + <newline/> |
158 | + <group string="Select parent account" attrs="{'invisible':[('states','!=','account_selection')]}" width="700"> |
159 | + <field name="account_list" colspan="4" nolabel="1" attrs="{'required':[('states','=','account_selection')]}"/> |
160 | + <newline/> |
161 | + <button special="cancel" colspan="2" string="Cancel" icon="gtk-cancel"/> |
162 | + <button name="step1" colspan="2" string="Next" type="object" icon="gtk-go-forward"/> |
163 | + </group> |
164 | + <newline/> |
165 | + <group string="Select Date-Period" attrs="{'invisible':[('states','!=','checktype')]}" width="700" > |
166 | + <field name="company_id" colspan="4" attrs="{'required':[('states','=','checktype')]}"/> |
167 | + <newline/> |
168 | + <field name="fiscalyear"/> |
169 | + <label colspan="2" string="(Keep empty for all open fiscal years)" align="0.0"/> |
170 | + <newline/> |
171 | + |
172 | + <field name="display_account" attrs="{'required':[('states','=','checktype')]}"/> |
173 | + <field name="sortbydate" attrs="{'required':[('states','=','checktype')]}"/> |
174 | + <field name="landscape"/> |
175 | + <field name="amount_currency"/> |
176 | + <field name="initial_balance"/> |
177 | + <newline/> |
178 | + <separator string="Filters" colspan="4"/> |
179 | + <field name="state" required="True"/> |
180 | + <newline/> |
181 | + <group attrs="{'invisible':[('state','=','none')]}" colspan="4"> |
182 | + <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4"> |
183 | + <separator string="Date Filter" colspan="4"/> |
184 | + <field name="date_from"/> |
185 | + <field name="date_to"/> |
186 | + </group> |
187 | + <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4"> |
188 | + <separator string="Filter on Periods" colspan="4"/> |
189 | + <field name="periods" colspan="4" nolabel="1"/> |
190 | + </group> |
191 | + </group> |
192 | + <button special="cancel" colspan="2" string="Cancel" icon="gtk-cancel"/> |
193 | + <button name="prints" colspan="2" string="Print Report" type="object" icon="gtk-print"/> |
194 | + </group> |
195 | + </form> |
196 | + </field> |
197 | + </record> |
198 | + |
199 | + <record id="action_general_ledger_cumulative_xml_report2" model="ir.actions.act_window"> |
200 | + <field name="name">**Cumulative general ledger</field> |
201 | + <field name="res_model">fl.account.general.ledger.cumulative.report</field> |
202 | + <field name="view_type">form</field> |
203 | + <field name="view_mode">form</field> |
204 | + <field name="view_id" ref="account_general_ledger_cumulative_report_form2"/> |
205 | + <field name="target">new</field> |
206 | + </record> |
207 | + <menuitem id="account_financial_report.menu_account_general_ledger_cumulative_report" action="action_general_ledger_cumulative_xml_report2" |
208 | + parent="account.menu_finance_generic_reporting" icon="STOCK_PRINT" |
209 | + name="**Cumulative general ledger" sequence="100"/> |
210 | + </data> |
211 | +</openerp> |
212 | |
213 | === added directory 'account_financial_report_web/i18n' |
214 | === added file 'account_financial_report_web/i18n/es.po' |
215 | --- account_financial_report_web/i18n/es.po 1970-01-01 00:00:00 +0000 |
216 | +++ account_financial_report_web/i18n/es.po 2014-01-29 11:51:34 +0000 |
217 | @@ -0,0 +1,367 @@ |
218 | +# Translation of OpenERP Server. |
219 | +# This file contains the translation of the following modules: |
220 | +# * fl_account_financial_report |
221 | +# |
222 | +msgid "" |
223 | +msgstr "" |
224 | +"Project-Id-Version: OpenERP Server 6.1\n" |
225 | +"Report-Msgid-Bugs-To: \n" |
226 | +"POT-Creation-Date: 2013-06-18 10:38+0000\n" |
227 | +"PO-Revision-Date: 2013-06-18 10:38+0000\n" |
228 | +"Last-Translator: <>\n" |
229 | +"Language-Team: \n" |
230 | +"MIME-Version: 1.0\n" |
231 | +"Content-Type: text/plain; charset=UTF-8\n" |
232 | +"Content-Transfer-Encoding: \n" |
233 | +"Plural-Forms: \n" |
234 | + |
235 | +#. module: fl_account_financial_report |
236 | +#: selection:fl.account.balance.full.report,state:0 |
237 | +#: selection:fl.account.general.ledger.cumulative.report,state:0 |
238 | +msgid "By Period" |
239 | +msgstr "Por periodo" |
240 | + |
241 | +#. module: fl_account_financial_report |
242 | +#: view:fl.account.balance.full.report:0 |
243 | +msgid "Full Account Balance2" |
244 | +msgstr "Balance de sumas y saldos" |
245 | + |
246 | +#. module: fl_account_financial_report |
247 | +#: view:fl.account.general.ledger.cumulative.report:0 |
248 | +msgid "Select parent account" |
249 | +msgstr "Seleccione cuenta" |
250 | + |
251 | +#. module: fl_account_financial_report |
252 | +#: field:fl.account.general.ledger.cumulative.report,sortbydate:0 |
253 | +msgid "Sort by" |
254 | +msgstr "Ordenar por" |
255 | + |
256 | +#. module: fl_account_financial_report |
257 | +#: model:ir.model,name:fl_account_financial_report.model_fl_account_balance_full_report |
258 | +msgid "fl.account.balance.full.report" |
259 | +msgstr "fl.account.balance.full.report" |
260 | + |
261 | +#. module: fl_account_financial_report |
262 | +#: code:addons/fl_account_financial_report/report/general_ledger.py:344 |
263 | +#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:348 |
264 | +#, python-format |
265 | +msgid "Initial balance" |
266 | +msgstr "Balance inicial" |
267 | + |
268 | +#. module: fl_account_financial_report |
269 | +#: field:fl.account.general.ledger.cumulative.report,initial_balance:0 |
270 | +msgid "Show initial balances" |
271 | +msgstr "Mostrar balance inicial" |
272 | + |
273 | +#. module: fl_account_financial_report |
274 | +#: view:fl.account.balance.full.report:0 |
275 | +#: view:fl.account.general.ledger.cumulative.report:0 |
276 | +msgid "Date Filter" |
277 | +msgstr "Filtro por fecha" |
278 | + |
279 | +#. module: fl_account_financial_report |
280 | +#: field:fl.account.general.ledger.cumulative.report,states:0 |
281 | +msgid "State" |
282 | +msgstr "Estado" |
283 | + |
284 | +#. module: fl_account_financial_report |
285 | +#: field:fl.account.balance.full.report,display_account:0 |
286 | +msgid "Display accounts " |
287 | +msgstr "Mostrar cuentas " |
288 | + |
289 | +#. module: fl_account_financial_report |
290 | +#: view:fl.account.general.ledger.cumulative.report:0 |
291 | +msgid "Print Report" |
292 | +msgstr "Imprimir informe" |
293 | + |
294 | +#. module: fl_account_financial_report |
295 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:227 |
296 | +#, python-format |
297 | +msgid "Date to must be set between %s and %s" |
298 | +msgstr "La fecha debe ser entre %s y %s" |
299 | + |
300 | +#. module: fl_account_financial_report |
301 | +#: code:addons/fl_account_financial_report/report/general_ledger.py:283 |
302 | +#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:287 |
303 | +#, python-format |
304 | +msgid "SI: " |
305 | +msgstr "SI: " |
306 | + |
307 | +#. module: fl_account_financial_report |
308 | +#: field:fl.account.balance.full.report,date_from:0 |
309 | +#: field:fl.account.general.ledger.cumulative.report,date_from:0 |
310 | +msgid "Start date" |
311 | +msgstr "Fecha de inicio" |
312 | + |
313 | +#. module: fl_account_financial_report |
314 | +#: view:fl.account.balance.full.report:0 |
315 | +#: view:fl.account.general.ledger.cumulative.report:0 |
316 | +msgid "Filter on Periods" |
317 | +msgstr "Filtro por periodos" |
318 | + |
319 | +#. module: fl_account_financial_report |
320 | +#: selection:fl.account.general.ledger.cumulative.report,sortbydate:0 |
321 | +msgid "Movement" |
322 | +msgstr "movimiento" |
323 | + |
324 | +#. module: fl_account_financial_report |
325 | +#: model:ir.model,name:fl_account_financial_report.model_fl_account_balance_full_report2 |
326 | +msgid "fl.account.balance.full.report2" |
327 | +msgstr "fl.account.balance.full.report2" |
328 | + |
329 | +#. module: fl_account_financial_report |
330 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:102 |
331 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:165 |
332 | +#, python-format |
333 | +msgid "Error !" |
334 | +msgstr "Error !" |
335 | + |
336 | +#. module: fl_account_financial_report |
337 | +#: field:fl.account.balance.full.report,periods:0 |
338 | +#: field:fl.account.general.ledger.cumulative.report,periods:0 |
339 | +msgid "Periods" |
340 | +msgstr "Periodos" |
341 | + |
342 | +#. module: fl_account_financial_report |
343 | +#: field:fl.account.balance.full.report,company_id:0 |
344 | +#: field:fl.account.general.ledger.cumulative.report,company_id:0 |
345 | +msgid "Company" |
346 | +msgstr "Compañia" |
347 | + |
348 | +#. module: fl_account_financial_report |
349 | +#: view:fl.account.general.ledger.cumulative.report:0 |
350 | +msgid "(Keep empty for all open fiscal years)" |
351 | +msgstr "(Mantener vacio para mostrar todos los ejercicios fiscales abiertos)" |
352 | + |
353 | +#. module: fl_account_financial_report |
354 | +#: selection:fl.account.balance.full.report,state:0 |
355 | +#: selection:fl.account.general.ledger.cumulative.report,state:0 |
356 | +msgid "No Filter" |
357 | +msgstr "Sin filtro" |
358 | + |
359 | +#. module: fl_account_financial_report |
360 | +#: selection:fl.account.general.ledger.cumulative.report,display_account:0 |
361 | +msgid "With balance is not equal to 0" |
362 | +msgstr "Con balance diferente a 0" |
363 | + |
364 | +#. module: fl_account_financial_report |
365 | +#: model:ir.model,name:fl_account_financial_report.model_account_balance_full_report |
366 | +msgid "account.balance.full.report" |
367 | +msgstr "account.balance.full.report" |
368 | + |
369 | +#. module: fl_account_financial_report |
370 | +#: selection:fl.account.general.ledger.cumulative.report,sortbydate:0 |
371 | +msgid "Date" |
372 | +msgstr "Fecha" |
373 | + |
374 | +#. module: fl_account_financial_report |
375 | +#: field:fl.account.general.ledger.cumulative.report,amount_currency:0 |
376 | +msgid "With Currency" |
377 | +msgstr "Mostrar divisa" |
378 | + |
379 | +#. module: fl_account_financial_report |
380 | +#: view:fl.account.balance.full.report:0 |
381 | +msgid "Accounts to include" |
382 | +msgstr "Cuentas a incluir" |
383 | + |
384 | +#. module: fl_account_financial_report |
385 | +#: view:fl.account.general.ledger.cumulative.report:0 |
386 | +msgid "General ledger" |
387 | +msgstr "Libro mayor" |
388 | + |
389 | +#. module: fl_account_financial_report |
390 | +#: help:fl.account.balance.full.report,display_account_level:0 |
391 | +msgid "Display accounts up to this level (0 to show all)" |
392 | +msgstr "Mostrar cuentas hasta este nivel de profundidad (0 para mostrar todas)" |
393 | + |
394 | +#. module: fl_account_financial_report |
395 | +#: selection:fl.account.balance.full.report,display_account:0 |
396 | +#: selection:fl.account.general.ledger.cumulative.report,display_account:0 |
397 | +msgid "With movements" |
398 | +msgstr "Con movimientos" |
399 | + |
400 | +#. module: fl_account_financial_report |
401 | +#: field:fl.account.general.ledger.cumulative.report,account_list:0 |
402 | +msgid "Account" |
403 | +msgstr "Cuenta" |
404 | + |
405 | +#. module: fl_account_financial_report |
406 | +#: model:ir.actions.report.xml,name:fl_account_financial_report.account_balance_full3 |
407 | +msgid "**Full account balance" |
408 | +msgstr "**Balance de sumas y saldos" |
409 | + |
410 | +#. module: fl_account_financial_report |
411 | +#: view:fl.account.general.ledger.cumulative.report:0 |
412 | +msgid "Filters" |
413 | +msgstr "Filtros" |
414 | + |
415 | +#. module: fl_account_financial_report |
416 | +#: selection:fl.account.balance.full.report,state:0 |
417 | +#: selection:fl.account.general.ledger.cumulative.report,state:0 |
418 | +msgid "By Date and Period" |
419 | +msgstr "Por fecha y periodo" |
420 | + |
421 | +#. module: fl_account_financial_report |
422 | +#: field:fl.account.balance.full.report,account_list:0 |
423 | +msgid "Root accounts" |
424 | +msgstr "Cuentas raiz" |
425 | + |
426 | +#. module: fl_account_financial_report |
427 | +#: code:addons/fl_account_financial_report/report/general_ledger.py:282 |
428 | +#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:286 |
429 | +#, python-format |
430 | +msgid "CI: " |
431 | +msgstr "CI: " |
432 | + |
433 | +#. module: fl_account_financial_report |
434 | +#: view:fl.account.general.ledger.cumulative.report:0 |
435 | +msgid "Select Date-Period" |
436 | +msgstr "Seleccionar fecha y periodo" |
437 | + |
438 | +#. module: fl_account_financial_report |
439 | +#: help:fl.account.general.ledger.cumulative.report,fiscalyear:0 |
440 | +msgid "Keep empty for all open fiscal year" |
441 | +msgstr "Mantener vacio para mostrar todos los ejercicios fiscales abiertos" |
442 | + |
443 | +#. module: fl_account_financial_report |
444 | +#: help:fl.account.balance.full.report,periods:0 |
445 | +#: help:fl.account.general.ledger.cumulative.report,periods:0 |
446 | +msgid "All periods in the fiscal year if empty" |
447 | +msgstr "Todos los periodos del ejercicio fiscal si no tiene contenido" |
448 | + |
449 | +#. module: fl_account_financial_report |
450 | +#: model:ir.actions.act_window,name:fl_account_financial_report.action_balance_full_xml_report3 |
451 | +msgid "**Full account balance3" |
452 | +msgstr "**Balance sumas y saldos" |
453 | + |
454 | +#. module: fl_account_financial_report |
455 | +#: view:fl.account.balance.full.report:0 |
456 | +msgid "Get Balance" |
457 | +msgstr "Obtener Balance" |
458 | + |
459 | +#. module: fl_account_financial_report |
460 | +#: code:addons/fl_account_financial_report/report/general_ledger.py:285 |
461 | +#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:289 |
462 | +#, python-format |
463 | +msgid "SR: " |
464 | +msgstr "SR: " |
465 | + |
466 | +#. module: fl_account_financial_report |
467 | +#: selection:fl.account.balance.full.report,state:0 |
468 | +#: selection:fl.account.general.ledger.cumulative.report,state:0 |
469 | +msgid "By Date" |
470 | +msgstr "By Date" |
471 | + |
472 | +#. module: fl_account_financial_report |
473 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:165 |
474 | +#, python-format |
475 | +msgid "La interseccion entre el periodo y fecha es vacio" |
476 | +msgstr "La interseccion entre el periodo y fecha es vacio" |
477 | + |
478 | +#. module: fl_account_financial_report |
479 | +#: selection:fl.account.balance.full.report,display_account:0 |
480 | +msgid "With balance" |
481 | +msgstr "Con balance" |
482 | + |
483 | +#. module: fl_account_financial_report |
484 | +#: selection:fl.account.general.ledger.cumulative.report,states:0 |
485 | +msgid "Check Type" |
486 | +msgstr "Check Type" |
487 | + |
488 | +#. module: fl_account_financial_report |
489 | +#: view:fl.account.general.ledger.cumulative.report:0 |
490 | +msgid "Next" |
491 | +msgstr "Next" |
492 | + |
493 | +#. module: fl_account_financial_report |
494 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:112 |
495 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:116 |
496 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:227 |
497 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:229 |
498 | +#, python-format |
499 | +msgid "UserError" |
500 | +msgstr "UserError" |
501 | + |
502 | +#. module: fl_account_financial_report |
503 | +#: field:fl.account.balance.full.report,date_to:0 |
504 | +#: field:fl.account.general.ledger.cumulative.report,date_to:0 |
505 | +msgid "End date" |
506 | +msgstr "Fecha de fin" |
507 | + |
508 | +#. module: fl_account_financial_report |
509 | +#: selection:fl.account.balance.full.report,display_account:0 |
510 | +#: selection:fl.account.general.ledger.cumulative.report,display_account:0 |
511 | +msgid "All" |
512 | +msgstr "Todo" |
513 | + |
514 | +#. module: fl_account_financial_report |
515 | +#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:229 |
516 | +#, python-format |
517 | +msgid "Date not in a defined fiscal year" |
518 | +msgstr "La fecha no se encuentra en un ejercicio fiscal definido" |
519 | + |
520 | +#. module: fl_account_financial_report |
521 | +#: model:ir.actions.act_window,name:fl_account_financial_report.action_general_ledger_cumulative_xml_report2 |
522 | +msgid "**Cumulative general ledger" |
523 | +msgstr "**Libro mayor acumulado" |
524 | + |
525 | +#. module: fl_account_financial_report |
526 | +#: field:fl.account.balance.full.report,state:0 |
527 | +#: field:fl.account.general.ledger.cumulative.report,state:0 |
528 | +msgid "Date/Period Filter" |
529 | +msgstr "Filtro fecha/periodo" |
530 | + |
531 | +#. module: fl_account_financial_report |
532 | +#: view:fl.account.balance.full.report:0 |
533 | +msgid "Period" |
534 | +msgstr "Periodo" |
535 | + |
536 | +#. module: fl_account_financial_report |
537 | +#: model:ir.model,name:fl_account_financial_report.model_fl_account_general_ledger_cumulative_report |
538 | +msgid "fl.account.general.ledger.cumulative.report" |
539 | +msgstr "fl.account.general.ledger.cumulative.report" |
540 | + |
541 | +#. module: fl_account_financial_report |
542 | +#: code:addons/fl_account_financial_report/report/general_ledger.py:284 |
543 | +#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:288 |
544 | +#, python-format |
545 | +msgid "OR: " |
546 | +msgstr "OR: " |
547 | + |
548 | +#. module: fl_account_financial_report |
549 | +#: field:fl.account.balance.full.report,fiscalyear:0 |
550 | +#: field:fl.account.general.ledger.cumulative.report,fiscalyear:0 |
551 | +msgid "Fiscal year" |
552 | +msgstr "Ejercicio fiscal" |
553 | + |
554 | +#. module: fl_account_financial_report |
555 | +#: field:fl.account.general.ledger.cumulative.report,landscape:0 |
556 | +msgid "Landscape Mode" |
557 | +msgstr "Modo apaisado" |
558 | + |
559 | +#. module: fl_account_financial_report |
560 | +#: field:fl.account.general.ledger.cumulative.report,display_account:0 |
561 | +msgid "Display accounts" |
562 | +msgstr "Mostrar cuentas" |
563 | + |
564 | +#. module: fl_account_financial_report |
565 | +#: field:fl.account.balance.full.report,display_account_level:0 |
566 | +msgid "Up to level" |
567 | +msgstr "Hasta el nivel" |
568 | + |
569 | +#. module: fl_account_financial_report |
570 | +#: view:fl.account.balance.full.report:0 |
571 | +#: view:fl.account.general.ledger.cumulative.report:0 |
572 | +msgid "Cancel" |
573 | +msgstr "Cancelar" |
574 | + |
575 | +#. module: fl_account_financial_report |
576 | +#: help:fl.account.balance.full.report,fiscalyear:0 |
577 | +msgid "Keep empty to use all open fiscal years to compute the balance" |
578 | +msgstr "Dejarlo vacio para usar todos los ejercicios fiscales abiertos para calcular el balance" |
579 | + |
580 | +#. module: fl_account_financial_report |
581 | +#: selection:fl.account.general.ledger.cumulative.report,states:0 |
582 | +msgid "Account Selection" |
583 | +msgstr "Selección de cuenta" |
584 | + |
585 | |
586 | === added directory 'account_financial_report_web/report' |
587 | === added file 'account_financial_report_web/report/__init__.py' |
588 | --- account_financial_report_web/report/__init__.py 1970-01-01 00:00:00 +0000 |
589 | +++ account_financial_report_web/report/__init__.py 2014-01-29 11:51:34 +0000 |
590 | @@ -0,0 +1,25 @@ |
591 | +# -*- encoding: utf-8 -*- |
592 | +############################################################################## |
593 | +# |
594 | +# OpenERP, Open Source Management Solution |
595 | +# Copyright (c) 2009 Factor Libre (http://factorlibre.com) All Rights Reserved. |
596 | +# |
597 | +# This program is free software: you can redistribute it and/or modify |
598 | +# it under the terms of the GNU Affero General Public License as published by |
599 | +# the Free Software Foundation, either version 3 of the License, or |
600 | +# (at your option) any later version. |
601 | +# |
602 | +# This program is distributed in the hope that it will be useful, |
603 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
604 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
605 | +# GNU Affero General Public License for more details. |
606 | +# |
607 | +# You should have received a copy of the GNU Affero General Public License |
608 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
609 | +# |
610 | +############################################################################## |
611 | +import account_balance |
612 | +import general_ledger |
613 | +import general_ledger_landscape |
614 | +import rml_parse |
615 | + |
616 | |
617 | === added file 'account_financial_report_web/report/account_balance.py' |
618 | --- account_financial_report_web/report/account_balance.py 1970-01-01 00:00:00 +0000 |
619 | +++ account_financial_report_web/report/account_balance.py 2014-01-29 11:51:34 +0000 |
620 | @@ -0,0 +1,314 @@ |
621 | +# -*- encoding: utf-8 -*- |
622 | +############################################################################## |
623 | +# |
624 | +# OpenERP, Open Source Management Solution |
625 | +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
626 | +# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. |
627 | +# Jordi Esteve <jesteve@zikzakmedia.com> |
628 | +# $Id$ |
629 | +# |
630 | +# This program is free software: you can redistribute it and/or modify |
631 | +# it under the terms of the GNU Affero General Public License as published by |
632 | +# the Free Software Foundation, either version 3 of the License, or |
633 | +# (at your option) any later version. |
634 | +# |
635 | +# This program is distributed in the hope that it will be useful, |
636 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
637 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
638 | +# GNU Affero General Public License for more details. |
639 | +# |
640 | +# You should have received a copy of the GNU Affero General Public License |
641 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
642 | +# |
643 | +############################################################################## |
644 | + |
645 | +import xml |
646 | +import copy |
647 | +from operator import itemgetter |
648 | +import time |
649 | +import datetime |
650 | +from report import report_sxw |
651 | +from tools import config |
652 | +#import decimal_precision as dp |
653 | + |
654 | +#import sys |
655 | + |
656 | +class account_balance(report_sxw.rml_parse): |
657 | + _name = "report.account.balance.full2" |
658 | + |
659 | + |
660 | + def __init__(self, cr, uid, name, context): |
661 | + super(account_balance, self).__init__(cr, uid, name, context) |
662 | + self.sum_debit = 0.00 |
663 | + self.sum_credit = 0.00 |
664 | + self.sum_balance = 0.00 |
665 | + self.sum_debit_fy = 0.00 |
666 | + self.sum_credit_fy = 0.00 |
667 | + self.sum_balance_fy = 0.00 |
668 | + self.date_lst = [] |
669 | + self.date_lst_string = '' |
670 | + self.localcontext.update({ |
671 | + 'time': time, |
672 | + 'lines': self.lines, |
673 | + 'get_fiscalyear_text': self.get_fiscalyear_text, |
674 | + 'get_periods_and_date_text': self.get_periods_and_date_text, |
675 | + }) |
676 | + self.context = context |
677 | + |
678 | + |
679 | + |
680 | + def set_context(self, objects, data, ids, report_type=None): |
681 | + new_ids = ids |
682 | + |
683 | + if (data['model'] == 'ir.ui.menu'): |
684 | + new_ids = data['form']['account_list'] |
685 | + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) |
686 | + super(account_balance, self).set_context(objects, data, new_ids, report_type=report_type) |
687 | + |
688 | + def get_fiscalyear_text(self, form): |
689 | + """ |
690 | + Returns the fiscal year text used on the report. |
691 | + """ |
692 | + fiscalyear_obj = self.pool.get('account.fiscalyear') |
693 | + fiscalyear = None |
694 | + |
695 | + if form.get('fiscalyear'): |
696 | + |
697 | + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'][0]) |
698 | + |
699 | + return fiscalyear.name or fiscalyear.code |
700 | + else: |
701 | + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) |
702 | + return "%s*" % (fiscalyear.name or fiscalyear.code) |
703 | + |
704 | + |
705 | + def get_periods_and_date_text(self, form): |
706 | + """ |
707 | + Returns the text with the periods/dates used on the report. |
708 | + """ |
709 | + period_obj = self.pool.get('account.period') |
710 | + periods_str = None |
711 | + fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid) |
712 | + period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id[0]),('special','=',False)]) |
713 | + if form['state'] in ['byperiod', 'all']: |
714 | + period_ids = form['periods'] |
715 | + periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)]) |
716 | + |
717 | + dates_str = None |
718 | + if form['state'] in ['bydate', 'all']: |
719 | + dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' ' |
720 | + |
721 | + if periods_str and dates_str: |
722 | + return "%s / %s" % (periods_str, dates_str) |
723 | + elif periods_str: |
724 | + return "%s" % periods_str |
725 | + elif dates_str: |
726 | + return "%s" % dates_str |
727 | + else: |
728 | + return '' |
729 | + |
730 | + |
731 | + def lines(self, form, ids={}, done=None, level=0): |
732 | + """ |
733 | + Returns all the data needed for the report lines |
734 | + (account info plus debit/credit/balance in the selected period |
735 | + and the full year) |
736 | + """ |
737 | + |
738 | + if not ids: |
739 | + ids = self.ids |
740 | + if not ids: |
741 | + return [] |
742 | + if not done: |
743 | + done = {} |
744 | + if form.has_key('account_list') and form['account_list']: |
745 | + account_ids = form['account_list'] |
746 | + del form['account_list'] |
747 | + res = {} |
748 | + result_acc = [] |
749 | + accounts_levels = {} |
750 | + account_obj = self.pool.get('account.account') |
751 | + period_obj = self.pool.get('account.period') |
752 | + fiscalyear_obj = self.pool.get('account.fiscalyear') |
753 | + |
754 | + # Get the fiscal year |
755 | + fiscalyear = None |
756 | + if form.get('fiscalyear'): |
757 | + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'][0]) |
758 | + else: |
759 | + fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid)) |
760 | + |
761 | + # |
762 | + # Get the accounts |
763 | + # |
764 | + child_ids = account_obj._get_children_and_consol(self.cr, self.uid, account_ids, self.context) |
765 | + if child_ids: |
766 | + account_ids = child_ids |
767 | + |
768 | + # |
769 | + # Calculate the FY Balance. |
770 | + # (from full fiscal year without closing periods) |
771 | + # |
772 | + ctx = self.context.copy() |
773 | + |
774 | + if form.get('fiscalyear'): |
775 | + # Use only the current fiscal year |
776 | + ctx['fiscalyear'] = fiscalyear.id |
777 | + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)]) |
778 | + else: |
779 | + # Use all the open fiscal years |
780 | + open_fiscalyear_ids = fiscalyear_obj.search(self.cr, self.uid, [('state','=','draft')]) |
781 | + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','in',open_fiscalyear_ids),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)]) |
782 | + |
783 | + fy_balance = {} |
784 | + for acc in account_obj.read(self.cr, self.uid, account_ids, ['balance'], ctx): |
785 | + fy_balance[acc['id']] = acc['balance'] |
786 | + |
787 | + # |
788 | + # Calculate the FY Debit/Credit |
789 | + # (from full fiscal year without opening or closing periods) |
790 | + # |
791 | + ctx = self.context.copy() |
792 | + ctx['fiscalyear'] = fiscalyear.id |
793 | + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)]) |
794 | + |
795 | + fy_debit = {} |
796 | + fy_credit = {} |
797 | + for acc in account_obj.read(self.cr, self.uid, account_ids, ['debit','credit','balance'], ctx): |
798 | + fy_debit[acc['id']] = acc['debit'] |
799 | + fy_credit[acc['id']] = acc['credit'] |
800 | + |
801 | + # |
802 | + # Calculate the period Debit/Credit |
803 | + # (from the selected period or all the non special periods in the fy) |
804 | + # |
805 | + ctx = self.context.copy() |
806 | + """tx['state'] = form['context'].get('state','all')""" |
807 | + ctx['fiscalyear'] = fiscalyear.id |
808 | + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)]) |
809 | + if form['state'] in ['byperiod', 'all']: |
810 | + ctx['periods'] = form['periods'] |
811 | + if form['state'] in ['bydate', 'all']: |
812 | + ctx['date_from'] = form['date_from'] |
813 | + ctx['date_to'] = form['date_to'] |
814 | + |
815 | + accounts = account_obj.read(self.cr, self.uid, account_ids, ['type','code','name','debit','credit','balance','parent_id'], ctx) |
816 | + # In some versions of OpenERP server, the order of the read records differs from the order of the ids of the records |
817 | + accounts.sort(lambda x,y: cmp(x['code'], y['code'])) |
818 | + |
819 | + # |
820 | + # Calculate the period initial Balance |
821 | + # (fy balance minus the balance from the start of the selected period |
822 | + # to the end of the year) |
823 | + # |
824 | + ctx = self.context.copy() |
825 | + """ctx['state'] = form['context'].get('state','all')""" |
826 | + ctx['fiscalyear'] = fiscalyear.id |
827 | + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)]) |
828 | + if form['state'] in ['byperiod', 'all']: |
829 | + ctx['periods'] = form['periods'] |
830 | + date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])]) |
831 | + ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','>=',date_start),('special','=',False)]) |
832 | + if form['state'] in ['bydate', 'all']: |
833 | + ctx['date_from'] = form['date_from'] |
834 | + ctx['date_to'] = fiscalyear.date_stop |
835 | + |
836 | + period_balanceinit = {} |
837 | + for acc in account_obj.read(self.cr, self.uid, account_ids, ['balance'], ctx): |
838 | + period_balanceinit[acc['id']] = fy_balance[acc['id']] - acc['balance'] |
839 | + |
840 | + # |
841 | + # Generate the report lines (checking each account) |
842 | + # |
843 | + decimal_precision_obj = self.pool.get('decimal.precision') |
844 | + ids = decimal_precision_obj.search(self.cr, self.uid, [('name', '=', 'Account')]) |
845 | + digits = decimal_precision_obj.browse(self.cr, self.uid, ids)[0].digits |
846 | + #print >>sys.stderr, 'digits',digits |
847 | + |
848 | + for account in accounts: |
849 | + account_id = account['id'] |
850 | + |
851 | + if account_id in done: |
852 | + continue |
853 | + |
854 | + done[account_id] = 1 |
855 | + |
856 | + # |
857 | + # Calculate the account level |
858 | + # |
859 | + parent_id = account['parent_id'] |
860 | + if parent_id: |
861 | + if isinstance(parent_id, tuple): |
862 | + parent_id = parent_id[0] |
863 | + account_level = accounts_levels.get(parent_id, 0) + 1 |
864 | + else: |
865 | + account_level = level |
866 | + accounts_levels[account_id] = account_level |
867 | + |
868 | + # |
869 | + # Check if we need to include this level |
870 | + # |
871 | + if not form['display_account_level'] or account_level <= form['display_account_level']: |
872 | + # |
873 | + # Copy the account values |
874 | + # |
875 | + res = { |
876 | + 'id' : account_id, |
877 | + 'type' : account['type'], |
878 | + 'code': account['code'], |
879 | + 'name': account['name'], |
880 | + 'level': account_level, |
881 | + 'balanceinit': period_balanceinit[account_id], |
882 | + 'debit': account['debit'], |
883 | + 'credit': account['credit'], |
884 | + 'balance': period_balanceinit[account_id]+account['balance'], |
885 | + 'balanceinit_fy': fy_balance[account_id]-fy_debit[account_id]+fy_credit[account_id], |
886 | + 'debit_fy': fy_debit[account_id], |
887 | + 'credit_fy': fy_credit[account_id], |
888 | + 'balance_fy': fy_balance[account_id], |
889 | + 'parent_id': account['parent_id'], |
890 | + 'bal_type': '', |
891 | + } |
892 | + |
893 | + # |
894 | + # Round the values to zero if needed (-0.000001 ~= 0) |
895 | + # |
896 | + res['balance'] = round(res['balance'],digits) |
897 | + res['balance_fy'] = round(res['balance_fy'],digits) |
898 | + res['balanceinit'] = round(res['balanceinit'],digits) |
899 | + res['balanceinit_fy'] = round(res['balanceinit_fy'],digits) |
900 | + res['debit'] = round(res['debit'],digits) |
901 | + res['credit'] = round(res['credit'],digits) |
902 | + #if abs(res['balance']) < 0.5 * 10**-int(config['price_accuracy']): |
903 | + # res['balance'] = 0.0 |
904 | + #if abs(res['balance_fy']) < 0.5 * 10**-int(config['price_accuracy']): |
905 | + # res['balance_fy'] = 0.0 |
906 | + #if abs(res['balanceinit']) < 0.5 * 10**-int(config['price_accuracy']): |
907 | + # res['balanceinit'] = 0.0 |
908 | + #if abs(res['balanceinit_fy']) < 0.5 * 10**-int(config['price_accuracy']): |
909 | + # res['balanceinit_fy'] = 0.0 |
910 | + |
911 | + # |
912 | + # Check whether we must include this line in the report or not |
913 | + # |
914 | + if form['display_account'] == 'bal_mouvement' and account['parent_id']: |
915 | + # Include accounts with movements |
916 | + if res['balance'] <> 0.0 \ |
917 | + or res['debit'] <> 0.0 \ |
918 | + or res['credit'] <> 0.0: |
919 | + # if abs(res['balance']) >= 0.5 * 10**-int(config['price_accuracy']) \ |
920 | + # or abs(res['credit']) >= 0.5 * 10**-int(config['price_accuracy']) \ |
921 | + # or abs(res['debit']) >= 0.5 * 10**-int(config['price_accuracy']): |
922 | + result_acc.append(res) |
923 | + elif form['display_account'] == 'bal_solde' and account['parent_id']: |
924 | + # Include accounts with balance |
925 | + #if abs(res['balance']) >= 0.5 * 10**-int(config['price_accuracy']): |
926 | + if res['balance'] <> 0.0 : |
927 | + result_acc.append(res) |
928 | + else: |
929 | + # Include all accounts |
930 | + result_acc.append(res) |
931 | + return result_acc |
932 | + |
933 | +report_sxw.report_sxw('report.account.balance.full2', 'account.account', 'addons/account_financial_report/report/account_balance_full.rml', parser=account_balance, header=False) |
934 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
935 | |
936 | === added file 'account_financial_report_web/report/general_ledger.py' |
937 | --- account_financial_report_web/report/general_ledger.py 1970-01-01 00:00:00 +0000 |
938 | +++ account_financial_report_web/report/general_ledger.py 2014-01-29 11:51:34 +0000 |
939 | @@ -0,0 +1,412 @@ |
940 | +# -*- encoding: utf-8 -*- |
941 | +############################################################################## |
942 | +# |
943 | +# Copyright (c) 2005-2006 CamptoCamp |
944 | +# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. |
945 | +# Jordi Esteve <jesteve@zikzakmedia.com> |
946 | +# |
947 | +# WARNING: This program as such is intended to be used by professional |
948 | +# programmers who take the whole responsability of assessing all potential |
949 | +# consequences resulting from its eventual inadequacies and bugs |
950 | +# End users who are looking for a ready-to-use solution with commercial |
951 | +# garantees and support are strongly adviced to contract a Free Software |
952 | +# Service Company |
953 | +# |
954 | +# This program is Free Software; you can redistribute it and/or |
955 | +# modify it under the terms of the GNU Affero General Public License |
956 | +# as published by the Free Software Foundation; either version 2 |
957 | +# of the License, or (at your option) any later version. |
958 | +# |
959 | +# This program is distributed in the hope that it will be useful, |
960 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
961 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
962 | +# GNU Affero General Public License for more details. |
963 | +# |
964 | +# You should have received a copy of the GNU Affero General Public License |
965 | +# along with this program; if not, write to the Free Software |
966 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
967 | +# |
968 | +############################################################################## |
969 | + |
970 | +import time |
971 | +from report import report_sxw |
972 | +from tools import config |
973 | +from tools.translate import _ |
974 | +import rml_parse |
975 | + |
976 | +class general_ledger(rml_parse.rml_parse): |
977 | + _name = 'report.account.general.ledger.cumulative2' |
978 | + |
979 | + def set_context(self, objects, data, ids, report_type = None): |
980 | + self.get_context_date_period(data['form']) |
981 | + new_ids = [] |
982 | + if (data['model'] == 'account.account'): |
983 | + new_ids = ids |
984 | + else: |
985 | + new_ids = data['form']['account_list'] |
986 | + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) |
987 | + super(general_ledger, self).set_context(objects, data, new_ids, report_type) |
988 | + |
989 | + |
990 | + def __init__(self, cr, uid, name, context): |
991 | + super(general_ledger, self).__init__(cr, uid, name, context=context) |
992 | + self.query = "" # SQL query to get account moves for given date or period |
993 | + self.min_date = "" # Min date of the given date or period |
994 | + self.ctx = {} # Context for given date or period |
995 | + self.ctxfy = {} # Context from the date start or first period of the fiscal year |
996 | + self.child_ids = "" |
997 | + self.tot_currency = 0.0 |
998 | + self.balance_accounts = {} |
999 | + self.localcontext.update( { |
1000 | + 'time': time, |
1001 | + 'lines': self.lines, |
1002 | + 'sum_debit_account': self._sum_debit_account, |
1003 | + 'sum_credit_account': self._sum_credit_account, |
1004 | + 'sum_balance_account': self._sum_balance_account, |
1005 | + 'get_children_accounts': self.get_children_accounts, |
1006 | + 'sum_currency_amount_account': self._sum_currency_amount_account, |
1007 | + 'get_fiscalyear':self.get_fiscalyear, |
1008 | + 'get_periods':self.get_periods, |
1009 | + }) |
1010 | + self.context = context |
1011 | + |
1012 | + |
1013 | + def get_fiscalyear(self, form): |
1014 | + res=[] |
1015 | + if form.has_key('fiscalyear'): |
1016 | + fisc_id = form['fiscalyear'][0] |
1017 | + if not (fisc_id): |
1018 | + return '' |
1019 | + self.cr.execute("SELECT name FROM account_fiscalyear WHERE id = %s" , (int(fisc_id),)) |
1020 | + res=self.cr.fetchone() |
1021 | + return res and res[0] or '' |
1022 | + |
1023 | + |
1024 | + def get_periods(self, form): |
1025 | + result='' |
1026 | + if form.has_key('periods') and form['periods']: |
1027 | + period_ids = ",".join([str(x) for x in form['periods'] if x]) |
1028 | + self.cr.execute("SELECT name FROM account_period WHERE id in (%s)" % (period_ids)) |
1029 | + res = self.cr.fetchall() |
1030 | + len_res = len(res) |
1031 | + for r in res: |
1032 | + if (r == res[len_res-1]): |
1033 | + result+=r[0]+". " |
1034 | + else: |
1035 | + result+=r[0]+", " |
1036 | + elif form.has_key('date_from') and form.has_key('date_to'): |
1037 | + result = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' ' |
1038 | + else: |
1039 | + fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear'][0]) |
1040 | + res = fy_obj.period_ids |
1041 | + len_res = len(res) |
1042 | + for r in res: |
1043 | + if r == res[len_res-1]: |
1044 | + result+=r.name+". " |
1045 | + else: |
1046 | + result+=r.name+", " |
1047 | + |
1048 | + return str(result and result[:-1]) or '' |
1049 | + |
1050 | + |
1051 | + def _calc_contrepartie(self, cr, uid, ids, context={}): |
1052 | + result = {} |
1053 | + #for id in ids: |
1054 | + # result.setdefault(id, False) |
1055 | + for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): |
1056 | + # For avoid long text in the field we will limit it to 5 lines |
1057 | + # |
1058 | + result[account_line.id] = ' ' |
1059 | + num_id_move = str(account_line.move_id.id) |
1060 | + num_id_line = str(account_line.id) |
1061 | + account_id = str(account_line.account_id.id) |
1062 | + # search the basic account |
1063 | + # We have the account ID we will search all account move line from now until this time |
1064 | + # We are in the case of we are on the top of the account move Line |
1065 | + cr.execute("SELECT distinct(ac.code) as code_rest,ac.name as name_rest "\ |
1066 | + "FROM account_account AS ac, account_move_line mv "\ |
1067 | + "WHERE ac.id = mv.account_id and mv.move_id = " + num_id_move + " and mv.account_id <> " + account_id ) |
1068 | + res_mv = cr.dictfetchall() |
1069 | + # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line |
1070 | + if (len(res_mv) >=1): |
1071 | + concat = '' |
1072 | + rup_id = 0 |
1073 | + for move_rest in res_mv: |
1074 | + concat = concat + move_rest['code_rest'] + '|' |
1075 | + result[account_line.id] = concat |
1076 | + if rup_id >5: |
1077 | + # we need to stop the computing and to escape but before we will add "..." |
1078 | + result[account_line.id] = concat + '...' |
1079 | + break |
1080 | + rup_id+=1 |
1081 | + return result |
1082 | + |
1083 | + |
1084 | + def get_context_date_period(self, form): |
1085 | + date_min = period_min = False |
1086 | + |
1087 | + # ctx: Context for the given date or period |
1088 | + ctx = self.context.copy() |
1089 | + if 'fiscalyear' in form and form['fiscalyear']: |
1090 | + ctx['fiscalyear'] = form['fiscalyear'][0] |
1091 | + if form['state'] in ['byperiod', 'all']: |
1092 | + ctx['periods'] = form['periods'] |
1093 | + if form['state'] in ['bydate', 'all']: |
1094 | + ctx['date_from'] = form['date_from'] |
1095 | + ctx['date_to'] = form['date_to'] |
1096 | + if 'periods' not in ctx: |
1097 | + ctx['periods'] = [] |
1098 | + self.ctx = ctx |
1099 | + print ctx |
1100 | + self.query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx) |
1101 | + # ctxfy: Context from the date start / first period of the fiscal year |
1102 | + ctxfy = ctx.copy() |
1103 | + ctxfy['periods'] = ctx['periods'][:] |
1104 | + |
1105 | + if form['state'] in ['byperiod', 'all'] and len(ctx['periods']): |
1106 | + self.cr.execute("""SELECT id, date_start, fiscalyear_id |
1107 | + FROM account_period |
1108 | + WHERE date_start = (SELECT min(date_start) FROM account_period WHERE id in (%s))""" |
1109 | + % (','.join([str(x) for x in ctx['periods']]))) |
1110 | + res = self.cr.dictfetchone() |
1111 | + period_min = res['date_start'] |
1112 | + self.cr.execute("""SELECT id |
1113 | + FROM account_period |
1114 | + WHERE fiscalyear_id in (%s) AND date_start < '%s'""" |
1115 | + % (res['fiscalyear_id'], res['date_start'])) |
1116 | + ids = filter(None, map(lambda x:x[0], self.cr.fetchall())) |
1117 | + ctxfy['periods'].extend(ids) |
1118 | + |
1119 | + if form['state'] in ['bydate', 'all']: |
1120 | + self.cr.execute("""SELECT date_start |
1121 | + FROM account_fiscalyear |
1122 | + WHERE '%s' BETWEEN date_start AND date_stop""" % (ctx['date_from'])) |
1123 | + res = self.cr.dictfetchone() |
1124 | + ctxfy['date_from'] = res['date_start'] |
1125 | + date_min = form['date_from'] |
1126 | + |
1127 | + if form['state'] == 'none' or (form['state'] == 'byperiod' and not len(ctx['periods'])): |
1128 | + if 'fiscalyear' in form and form['fiscalyear']: |
1129 | + sql = """SELECT id, date_start |
1130 | + FROM account_period |
1131 | + WHERE fiscalyear_id in (%s) |
1132 | + ORDER BY date_start""" % (ctx['fiscalyear']) |
1133 | + else: |
1134 | + sql = """SELECT id, date_start |
1135 | + FROM account_period |
1136 | + WHERE fiscalyear_id in (SELECT id FROM account_fiscalyear WHERE state='draft') |
1137 | + ORDER BY date_start""" |
1138 | + self.cr.execute(sql) |
1139 | + res = self.cr.dictfetchall() |
1140 | + period_min = res[0]['date_start'] |
1141 | + ids = filter(None, map(lambda x:x['id'], res)) |
1142 | + ctxfy['periods'] = ids |
1143 | + self.ctxfy = ctxfy |
1144 | + |
1145 | + if not period_min: |
1146 | + self.min_date = date_min |
1147 | + elif not date_min: |
1148 | + self.min_date = period_min |
1149 | + else: |
1150 | + # If period and date are given, the maximum of the min dates is choosed |
1151 | + if period_min < date_min: |
1152 | + self.min_date = date_min |
1153 | + else: |
1154 | + self.min_date = period_min |
1155 | + |
1156 | + |
1157 | + def get_children_accounts(self, account, form): |
1158 | + move_line_obj = self.pool.get('account.move.line') |
1159 | + account_obj = self.pool.get('account.account') |
1160 | + invoice_obj = self.pool.get('account.invoice') |
1161 | + self.child_ids = account_obj.search(self.cr, self.uid, [('parent_id', 'child_of', form['account_list'])]) |
1162 | + res = [] |
1163 | + ctx = self.ctx.copy() |
1164 | + if account and account.child_consol_ids: # add ids of consolidated childs also of selected account |
1165 | + ctx['consolidate_childs'] = True |
1166 | + ctx['account_id'] = account.id |
1167 | + ids_acc = account_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account.id])], context=ctx) |
1168 | + for child_id in ids_acc: |
1169 | + child_account = account_obj.browse(self.cr, self.uid, child_id) |
1170 | + balance_account = self._sum_balance_account(child_account,form) |
1171 | + self.balance_accounts[child_account.id] = balance_account |
1172 | + if form['display_account'] == 'bal_mouvement': |
1173 | + if child_account.type != 'view' \ |
1174 | + and len(move_line_obj.search(self.cr, self.uid, |
1175 | + [('account_id','=',child_account.id)], |
1176 | + context=ctx)) <> 0 : |
1177 | + res.append(child_account) |
1178 | + elif form['display_account'] == 'bal_solde': |
1179 | + if child_account.type != 'view' \ |
1180 | + and len(move_line_obj.search(self.cr, self.uid, |
1181 | + [('account_id','=',child_account.id)], |
1182 | + context=ctx)) <> 0 : |
1183 | + if balance_account <> 0.0: |
1184 | + res.append(child_account) |
1185 | + else: |
1186 | + if child_account.type != 'view' \ |
1187 | + and len(move_line_obj.search(self.cr, self.uid, |
1188 | + [('account_id','>=',child_account.id)], |
1189 | + context=ctx)) <> 0 : |
1190 | + res.append(child_account) |
1191 | + ## |
1192 | + if not len(res): |
1193 | + return [account] |
1194 | + else: |
1195 | + ## We will now compute initial balance |
1196 | + for move in res: |
1197 | + sql_balance_init = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit "\ |
1198 | + "FROM account_move_line l "\ |
1199 | + "WHERE l.account_id = " + str(move.id) + " AND %s" % (self.query) |
1200 | + self.cr.execute(sql_balance_init) |
1201 | + resultat = self.cr.dictfetchall() |
1202 | + if resultat[0] : |
1203 | + if resultat[0]['sum_debit'] == None: |
1204 | + sum_debit = 0 |
1205 | + else: |
1206 | + sum_debit = resultat[0]['sum_debit'] |
1207 | + if resultat[0]['sum_credit'] == None: |
1208 | + sum_credit = 0 |
1209 | + else: |
1210 | + sum_credit = resultat[0]['sum_credit'] |
1211 | + |
1212 | + move.init_credit = sum_credit |
1213 | + move.init_debit = sum_debit |
1214 | + else: |
1215 | + move.init_credit = 0 |
1216 | + move.init_debit = 0 |
1217 | + return res |
1218 | + |
1219 | + |
1220 | + def lines(self, account, form): |
1221 | + inv_types = { |
1222 | + 'out_invoice': _('CI: '), |
1223 | + 'in_invoice': _('SI: '), |
1224 | + 'out_refund': _('OR: '), |
1225 | + 'in_refund': _('SR: '), |
1226 | + } |
1227 | + |
1228 | + self.query |
1229 | + |
1230 | + if form['sortbydate'] == 'sort_date': |
1231 | + sorttag = 'l.date' |
1232 | + else: |
1233 | + sorttag = 'j.code' |
1234 | + sql = """ |
1235 | + SELECT l.id, l.date, j.code, c.symbol AS currency_code, l.amount_currency, l.ref, l.name , l.debit, l.credit, l.period_id |
1236 | + FROM account_move_line as l |
1237 | + LEFT JOIN res_currency c on (l.currency_id=c.id) |
1238 | + JOIN account_journal j on (l.journal_id=j.id) |
1239 | + AND account_id = %%s |
1240 | + AND %s |
1241 | + ORDER by %s""" % (self.query, sorttag) |
1242 | + self.cr.execute(sql % account.id) |
1243 | + |
1244 | + res = self.cr.dictfetchall() |
1245 | + move_line_obj = self.pool.get('account.move.line') |
1246 | + account_obj = self.pool.get('account.account') |
1247 | + invoice_obj = self.pool.get('account.invoice') |
1248 | + |
1249 | + # Balance from init fiscal year to last date given by the user |
1250 | + accounts = account_obj.read(self.cr, self.uid, [account.id], ['balance'], self.ctxfy) |
1251 | + sum = accounts[0]['balance'] |
1252 | + |
1253 | + for l in reversed(res): |
1254 | + line = move_line_obj.browse(self.cr, self.uid, l['id']) |
1255 | + l['move'] = line.move_id.name_split |
1256 | + self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) |
1257 | + tmpres = self.cr.dictfetchall() |
1258 | + if len(tmpres) > 0 : |
1259 | + inv = invoice_obj.browse(self.cr, self.uid, tmpres[0]['id']) |
1260 | + l['ref'] = inv_types[inv.type] + ': '+str(inv.number) |
1261 | + if line.partner_id : |
1262 | + l['partner'] = line.partner_id.name |
1263 | + else : |
1264 | + l['partner'] = '' |
1265 | + l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] |
1266 | + |
1267 | + # Cumulative balance update |
1268 | + l['progress'] = sum |
1269 | + sum = sum - l['debit'] + l ['credit'] |
1270 | + |
1271 | + # Modification of currency amount |
1272 | + if (l['credit'] > 0): |
1273 | + if l['amount_currency'] != None: |
1274 | + l['amount_currency'] = abs(l['amount_currency']) * -1 |
1275 | + if l['amount_currency'] != None: |
1276 | + self.tot_currency = self.tot_currency + l['amount_currency'] |
1277 | + |
1278 | + decimal_precision_obj = self.pool.get('decimal.precision') |
1279 | + ids = decimal_precision_obj.search(self.cr, self.uid, [('name', '=', 'Account')]) |
1280 | + digits = decimal_precision_obj.browse(self.cr, self.uid, ids)[0].digits |
1281 | + |
1282 | + #if abs(sum) > 10**-int(config['price_accuracy']) and form['initial_balance']: |
1283 | + if round(sum,digits) <> 0.0 and form['initial_balance']: |
1284 | + res.insert(0, { |
1285 | + 'date': self.min_date, |
1286 | + 'name': _('Initial balance'), |
1287 | + 'progress': sum, |
1288 | + 'partner': '', |
1289 | + 'move': '', |
1290 | + 'ref': '', |
1291 | + 'debit': '', |
1292 | + 'credit': '', |
1293 | + 'amount_currency': '', |
1294 | + 'currency_code': '', |
1295 | + 'code': '', |
1296 | + 'line_corresp': '', |
1297 | + }) |
1298 | + |
1299 | + return res |
1300 | + |
1301 | + |
1302 | + def _sum_debit_account(self, account, form): |
1303 | + self.cr.execute("SELECT sum(debit) "\ |
1304 | + "FROM account_move_line l "\ |
1305 | + "WHERE l.account_id = %s AND %s " % (account.id, self.query)) |
1306 | + sum_debit = self.cr.fetchone()[0] or 0.0 |
1307 | + return sum_debit |
1308 | + |
1309 | + |
1310 | + def _sum_credit_account(self, account, form): |
1311 | + self.cr.execute("SELECT sum(credit) "\ |
1312 | + "FROM account_move_line l "\ |
1313 | + "WHERE l.account_id = %s AND %s " % (account.id, self.query)) |
1314 | + sum_credit = self.cr.fetchone()[0] or 0.0 |
1315 | + return sum_credit |
1316 | + |
1317 | + |
1318 | + def _sum_balance_account(self, account, form): |
1319 | + # Balance from init fiscal year to last date given by the user |
1320 | + accounts = self.pool.get('account.account').read(self.cr, self.uid, [account.id], ['balance'], self.ctxfy) |
1321 | + sum_balance = accounts[0]['balance'] |
1322 | + return sum_balance |
1323 | + |
1324 | + |
1325 | + def _set_get_account_currency_code(self, account_id): |
1326 | + self.cr.execute("SELECT c.symbol as code "\ |
1327 | + "FROM res_currency c, account_account as ac "\ |
1328 | + "WHERE ac.id = %s AND ac.currency_id = c.id" % (account_id)) |
1329 | + result = self.cr.fetchone() |
1330 | + if result: |
1331 | + self.account_currency = result[0] |
1332 | + else: |
1333 | + self.account_currency = False |
1334 | + |
1335 | + |
1336 | + def _sum_currency_amount_account(self, account, form): |
1337 | + self._set_get_account_currency_code(account.id) |
1338 | + self.cr.execute("SELECT sum(l.amount_currency) "\ |
1339 | + "FROM account_move_line as l, res_currency as rc "\ |
1340 | + "WHERE l.currency_id = rc.id AND l.account_id= %s AND %s" % (account.id, self.query)) |
1341 | + total = self.cr.fetchone() |
1342 | + if self.account_currency: |
1343 | + return_field = str(total[0]) + self.account_currency |
1344 | + return return_field |
1345 | + else: |
1346 | + currency_total = self.tot_currency = 0.0 |
1347 | + return currency_total |
1348 | + |
1349 | + |
1350 | +report_sxw.report_sxw('report.account.general.ledger.cumulative2', 'account.account', 'addons/account_financial_report/report/general_ledger.rml', parser=general_ledger, header=False) |
1351 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1352 | |
1353 | === added file 'account_financial_report_web/report/general_ledger_landscape.py' |
1354 | --- account_financial_report_web/report/general_ledger_landscape.py 1970-01-01 00:00:00 +0000 |
1355 | +++ account_financial_report_web/report/general_ledger_landscape.py 2014-01-29 11:51:34 +0000 |
1356 | @@ -0,0 +1,413 @@ |
1357 | +# -*- encoding: utf-8 -*- |
1358 | +############################################################################## |
1359 | +# |
1360 | +# Copyright (c) 2005-2006 CamptoCamp |
1361 | +# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. |
1362 | +# Jordi Esteve <jesteve@zikzakmedia.com> |
1363 | +# |
1364 | +# WARNING: This program as such is intended to be used by professional |
1365 | +# programmers who take the whole responsability of assessing all potential |
1366 | +# consequences resulting from its eventual inadequacies and bugs |
1367 | +# End users who are looking for a ready-to-use solution with commercial |
1368 | +# garantees and support are strongly adviced to contract a Free Software |
1369 | +# Service Company |
1370 | +# |
1371 | +# This program is Free Software; you can redistribute it and/or |
1372 | +# modify it under the terms of the GNU Affero General Public License |
1373 | +# as published by the Free Software Foundation; either version 2 |
1374 | +# of the License, or (at your option) any later version. |
1375 | +# |
1376 | +# This program is distributed in the hope that it will be useful, |
1377 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1378 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1379 | +# GNU Affero General Public License for more details. |
1380 | +# |
1381 | +# You should have received a copy of the GNU Affero General Public License |
1382 | +# along with this program; if not, write to the Free Software |
1383 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1384 | +# |
1385 | +############################################################################## |
1386 | + |
1387 | + |
1388 | +import time |
1389 | +from report import report_sxw |
1390 | +from tools.translate import _ |
1391 | +import rml_parse |
1392 | + |
1393 | + |
1394 | +class general_ledger_landscape(rml_parse.rml_parse): |
1395 | + _name = 'report.account.general.ledger.cumulative.landscape2' |
1396 | + |
1397 | + def set_context(self, objects, data, ids, report_type = None): |
1398 | + self.get_context_date_period(data['form']) |
1399 | + new_ids = [] |
1400 | + if (data['model'] == 'account.account'): |
1401 | + new_ids = ids |
1402 | + else: |
1403 | + new_ids = data['form']['account_list'] |
1404 | + objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) |
1405 | + super(general_ledger_landscape, self).set_context(objects, data, new_ids, report_type) |
1406 | + |
1407 | + |
1408 | + def __init__(self, cr, uid, name, context): |
1409 | + super(general_ledger_landscape, self).__init__(cr, uid, name, context=context) |
1410 | + self.query = "" # SQL query to get account moves for given date or period |
1411 | + self.min_date = "" # Min date of the given date or period |
1412 | + self.ctx = {} # Context for given date or period |
1413 | + self.ctxfy = {} # Context from the date start or first period of the fiscal year |
1414 | + self.child_ids = "" |
1415 | + self.tot_currency = 0.0 |
1416 | + self.balance_accounts = {} |
1417 | + self.localcontext.update( { |
1418 | + 'time': time, |
1419 | + 'lines': self.lines, |
1420 | + 'sum_debit_account': self._sum_debit_account, |
1421 | + 'sum_credit_account': self._sum_credit_account, |
1422 | + 'sum_balance_account': self._sum_balance_account, |
1423 | + 'get_children_accounts': self.get_children_accounts, |
1424 | + 'sum_currency_amount_account': self._sum_currency_amount_account, |
1425 | + 'get_fiscalyear':self.get_fiscalyear, |
1426 | + 'get_periods':self.get_periods, |
1427 | + }) |
1428 | + self.context = context |
1429 | + |
1430 | + |
1431 | + def get_fiscalyear(self, form): |
1432 | + res=[] |
1433 | + if form.has_key('fiscalyear'): |
1434 | + fisc_id = form['fiscalyear'][0] |
1435 | + if not (fisc_id): |
1436 | + return '' |
1437 | + self.cr.execute("SELECT name FROM account_fiscalyear WHERE id = %s" , (int(fisc_id),)) |
1438 | + res=self.cr.fetchone() |
1439 | + return res and res[0] or '' |
1440 | + |
1441 | + |
1442 | + def get_periods(self, form): |
1443 | + result='' |
1444 | + if form.has_key('periods') and form['periods']: |
1445 | + period_ids = ",".join([str(x) for x in form['periods']if x]) |
1446 | + self.cr.execute("SELECT name FROM account_period WHERE id in (%s)" % (period_ids)) |
1447 | + res = self.cr.fetchall() |
1448 | + len_res = len(res) |
1449 | + for r in res: |
1450 | + if (r == res[len_res-1]): |
1451 | + result+=r[0]+". " |
1452 | + else: |
1453 | + result+=r[0]+", " |
1454 | + elif form.has_key('date_from') and form.has_key('date_to'): |
1455 | + result = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' ' |
1456 | + else: |
1457 | + fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear']) |
1458 | + res = fy_obj.period_ids |
1459 | + len_res = len(res) |
1460 | + for r in res: |
1461 | + if r == res[len_res-1]: |
1462 | + result+=r.name+". " |
1463 | + else: |
1464 | + result+=r.name+", " |
1465 | + |
1466 | + return str(result and result[:-1]) or '' |
1467 | + |
1468 | + |
1469 | + def _calc_contrepartie(self, cr, uid, ids, context={}): |
1470 | + result = {} |
1471 | + #for id in ids: |
1472 | + # result.setdefault(id, False) |
1473 | + |
1474 | + for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): |
1475 | + # For avoid long text in the field we will limit it to 5 lines |
1476 | + # |
1477 | + result[account_line.id] = ' ' |
1478 | + num_id_move = str(account_line.move_id.id) |
1479 | + num_id_line = str(account_line.id) |
1480 | + account_id = str(account_line.account_id.id) |
1481 | + # search the basic account |
1482 | + # We have the account ID we will search all account move line from now until this time |
1483 | + # We are in the case of we are on the top of the account move Line |
1484 | + cr.execute("SELECT distinct(ac.code) as code_rest,ac.name as name_rest "\ |
1485 | + "FROM account_account AS ac, account_move_line mv "\ |
1486 | + "WHERE ac.id = mv.account_id and mv.move_id = " + num_id_move + " and mv.account_id <> " + account_id ) |
1487 | + res_mv = cr.dictfetchall() |
1488 | + # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line |
1489 | + if (len(res_mv) >=1): |
1490 | + concat = '' |
1491 | + rup_id = 0 |
1492 | + for move_rest in res_mv: |
1493 | + concat = concat + move_rest['code_rest'] + '|' |
1494 | + result[account_line.id] = concat |
1495 | + if rup_id >5: |
1496 | + # we need to stop the computing and to escape but before we will add "..." |
1497 | + result[account_line.id] = concat + '...' |
1498 | + break |
1499 | + rup_id+=1 |
1500 | + return result |
1501 | + |
1502 | + |
1503 | + def get_context_date_period(self, form): |
1504 | + date_min = period_min = False |
1505 | + |
1506 | + # ctx: Context for the given date or period |
1507 | + ctx = self.context.copy() |
1508 | + if 'fiscalyear' in form and form['fiscalyear']: |
1509 | + ctx['fiscalyear'] = form['fiscalyear'][0] |
1510 | + if form['state'] in ['byperiod', 'all']: |
1511 | + ctx['periods'] = form['periods'] |
1512 | + if form['state'] in ['bydate', 'all']: |
1513 | + ctx['date_from'] = form['date_from'] |
1514 | + ctx['date_to'] = form['date_to'] |
1515 | + if 'periods' not in ctx: |
1516 | + ctx['periods'] = [] |
1517 | + self.ctx = ctx |
1518 | + self.query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx) |
1519 | + |
1520 | + # ctxfy: Context from the date start / first period of the fiscal year |
1521 | + ctxfy = ctx.copy() |
1522 | + ctxfy['periods'] = ctx['periods'][:] |
1523 | + |
1524 | + if form['state'] in ['byperiod', 'all'] and len(ctx['periods']): |
1525 | + self.cr.execute("""SELECT id, date_start, fiscalyear_id |
1526 | + FROM account_period |
1527 | + WHERE date_start = (SELECT min(date_start) FROM account_period WHERE id in (%s))""" |
1528 | + % (','.join([str(x) for x in ctx['periods']]))) |
1529 | + res = self.cr.dictfetchone() |
1530 | + period_min = res['date_start'] |
1531 | + self.cr.execute("""SELECT id |
1532 | + FROM account_period |
1533 | + WHERE fiscalyear_id in (%s) AND date_start < '%s'""" |
1534 | + % (res['fiscalyear_id'], res['date_start'])) |
1535 | + ids = filter(None, map(lambda x:x[0], self.cr.fetchall())) |
1536 | + ctxfy['periods'].extend(ids) |
1537 | + |
1538 | + if form['state'] in ['bydate', 'all']: |
1539 | + self.cr.execute("""SELECT date_start |
1540 | + FROM account_fiscalyear |
1541 | + WHERE '%s' BETWEEN date_start AND date_stop""" % (ctx['date_from'])) |
1542 | + res = self.cr.dictfetchone() |
1543 | + ctxfy['date_from'] = res['date_start'] |
1544 | + date_min = form['date_from'] |
1545 | + |
1546 | + if form['state'] == 'none' or (form['state'] == 'byperiod' and not len(ctx['periods'])): |
1547 | + if 'fiscalyear' in form and form['fiscalyear']: |
1548 | + sql = """SELECT id, date_start |
1549 | + FROM account_period |
1550 | + WHERE fiscalyear_id in (%s) |
1551 | + ORDER BY date_start""" % (ctx['fiscalyear']) |
1552 | + else: |
1553 | + sql = """SELECT id, date_start |
1554 | + FROM account_period |
1555 | + WHERE fiscalyear_id in (SELECT id FROM account_fiscalyear WHERE state='draft') |
1556 | + ORDER BY date_start""" |
1557 | + self.cr.execute(sql) |
1558 | + res = self.cr.dictfetchall() |
1559 | + period_min = res[0]['date_start'] |
1560 | + ids = filter(None, map(lambda x:x['id'], res)) |
1561 | + ctxfy['periods'] = ids |
1562 | + self.ctxfy = ctxfy |
1563 | + |
1564 | + if not period_min: |
1565 | + self.min_date = date_min |
1566 | + elif not date_min: |
1567 | + self.min_date = period_min |
1568 | + else: |
1569 | + # If period and date are given, the maximum of the min dates is choosed |
1570 | + if period_min < date_min: |
1571 | + self.min_date = date_min |
1572 | + else: |
1573 | + self.min_date = period_min |
1574 | + |
1575 | + |
1576 | + def get_children_accounts(self, account, form): |
1577 | + move_line_obj = self.pool.get('account.move.line') |
1578 | + account_obj = self.pool.get('account.account') |
1579 | + invoice_obj = self.pool.get('account.invoice') |
1580 | + self.child_ids = account_obj.search(self.cr, self.uid, [('parent_id', 'child_of', form['account_list'])]) |
1581 | + |
1582 | + res = [] |
1583 | + ctx = self.ctx.copy() |
1584 | + if account and account.child_consol_ids: # add ids of consolidated childs also of selected account |
1585 | + ctx['consolidate_childs'] = True |
1586 | + ctx['account_id'] = account.id |
1587 | + ids_acc = account_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account.id])], context=ctx) |
1588 | + for child_id in ids_acc: |
1589 | + child_account = account_obj.browse(self.cr, self.uid, child_id) |
1590 | + balance_account = self._sum_balance_account(child_account,form) |
1591 | + self.balance_accounts[child_account.id] = balance_account |
1592 | + if form['display_account'] == 'bal_mouvement': |
1593 | + if child_account.type != 'view' \ |
1594 | + and len(move_line_obj.search(self.cr, self.uid, |
1595 | + [('account_id','=',child_account.id)], |
1596 | + context=ctx)) <> 0 : |
1597 | + res.append(child_account) |
1598 | + elif form['display_account'] == 'bal_solde': |
1599 | + if child_account.type != 'view' \ |
1600 | + and len(move_line_obj.search(self.cr, self.uid, |
1601 | + [('account_id','=',child_account.id)], |
1602 | + context=ctx)) <> 0 : |
1603 | + if balance_account <> 0.0: |
1604 | + res.append(child_account) |
1605 | + else: |
1606 | + if child_account.type != 'view' \ |
1607 | + and len(move_line_obj.search(self.cr, self.uid, |
1608 | + [('account_id','>=',child_account.id)], |
1609 | + context=ctx)) <> 0 : |
1610 | + res.append(child_account) |
1611 | + ## |
1612 | + if not len(res): |
1613 | + return [account] |
1614 | + else: |
1615 | + ## We will now compute initial balance |
1616 | + for move in res: |
1617 | + sql_balance_init = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit "\ |
1618 | + "FROM account_move_line l "\ |
1619 | + "WHERE l.account_id = " + str(move.id) + " AND %s" % (self.query) |
1620 | + self.cr.execute(sql_balance_init) |
1621 | + resultat = self.cr.dictfetchall() |
1622 | + if resultat[0] : |
1623 | + if resultat[0]['sum_debit'] == None: |
1624 | + sum_debit = 0 |
1625 | + else: |
1626 | + sum_debit = resultat[0]['sum_debit'] |
1627 | + if resultat[0]['sum_credit'] == None: |
1628 | + sum_credit = 0 |
1629 | + else: |
1630 | + sum_credit = resultat[0]['sum_credit'] |
1631 | + |
1632 | + move.init_credit = sum_credit |
1633 | + move.init_debit = sum_debit |
1634 | + else: |
1635 | + move.init_credit = 0 |
1636 | + move.init_debit = 0 |
1637 | + return res |
1638 | + |
1639 | + |
1640 | + def lines(self, account, form): |
1641 | + inv_types = { |
1642 | + 'out_invoice': _('CI: '), |
1643 | + 'in_invoice': _('SI: '), |
1644 | + 'out_refund': _('OR: '), |
1645 | + 'in_refund': _('SR: '), |
1646 | + } |
1647 | + |
1648 | + if form['sortbydate'] == 'sort_date': |
1649 | + sorttag = 'l.date' |
1650 | + else: |
1651 | + sorttag = 'j.code' |
1652 | + sql = """ |
1653 | + SELECT l.id, l.date, j.code, c.symbol AS currency_code, l.amount_currency, l.ref, l.name , l.debit, l.credit, l.period_id |
1654 | + FROM account_move_line as l |
1655 | + LEFT JOIN res_currency c on (l.currency_id=c.id) |
1656 | + JOIN account_journal j on (l.journal_id=j.id) |
1657 | + AND account_id = %%s |
1658 | + AND %s |
1659 | + ORDER by %s""" % (self.query, sorttag) |
1660 | + self.cr.execute(sql % account.id) |
1661 | + |
1662 | + res = self.cr.dictfetchall() |
1663 | + move_line_obj = self.pool.get('account.move.line') |
1664 | + account_obj = self.pool.get('account.account') |
1665 | + invoice_obj = self.pool.get('account.invoice') |
1666 | + |
1667 | + # Balance from init fiscal year to last date given by the user |
1668 | + accounts = account_obj.read(self.cr, self.uid, [account.id], ['balance'], self.ctxfy) |
1669 | + sum = accounts[0]['balance'] |
1670 | + |
1671 | + for l in reversed(res): |
1672 | + line = move_line_obj.browse(self.cr, self.uid, l['id']) |
1673 | + l['move'] = line.move_id.name_split |
1674 | + self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) |
1675 | + tmpres = self.cr.dictfetchall() |
1676 | + if len(tmpres) > 0 : |
1677 | + inv = invoice_obj.browse(self.cr, self.uid, tmpres[0]['id']) |
1678 | + l['ref'] = inv_types[inv.type] + ': '+str(inv.number) |
1679 | + if line.partner_id : |
1680 | + l['partner'] = line.partner_id.name |
1681 | + else : |
1682 | + l['partner'] = '' |
1683 | + l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] |
1684 | + |
1685 | + # Cumulative balance update |
1686 | + l['progress'] = sum |
1687 | + sum = sum - (l['debit'] or 0) + (l['credit'] or 0) |
1688 | + |
1689 | + # Modification of currency amount |
1690 | + if (l['credit'] > 0): |
1691 | + if l['amount_currency'] != None: |
1692 | + l['amount_currency'] = abs(l['amount_currency']) * -1 |
1693 | + if l['amount_currency'] != None: |
1694 | + self.tot_currency = self.tot_currency + l['amount_currency'] |
1695 | + |
1696 | + decimal_precision_obj = self.pool.get('decimal.precision') |
1697 | + ids = decimal_precision_obj.search(self.cr, self.uid, [('name', '=', 'Account')]) |
1698 | + digits = decimal_precision_obj.browse(self.cr, self.uid, ids)[0].digits |
1699 | + |
1700 | + #if abs(sum) > 10**-int(config['price_accuracy']) and form['initial_balance']: |
1701 | + if round(sum,digits) <> 0.0 and form['initial_balance']: |
1702 | + res.insert(0, { |
1703 | + 'date': self.min_date, |
1704 | + 'name': _('Initial balance'), |
1705 | + 'progress': sum, |
1706 | + 'partner': '', |
1707 | + 'move': '', |
1708 | + 'ref': '', |
1709 | + 'debit': '', |
1710 | + 'credit': '', |
1711 | + 'amount_currency': '', |
1712 | + 'currency_code': '', |
1713 | + 'code': '', |
1714 | + 'line_corresp': '', |
1715 | + }) |
1716 | + |
1717 | + return res |
1718 | + |
1719 | + |
1720 | + def _sum_debit_account(self, account, form): |
1721 | + self.cr.execute("SELECT sum(debit) "\ |
1722 | + "FROM account_move_line l "\ |
1723 | + "WHERE l.account_id = %s AND %s " % (account.id, self.query)) |
1724 | + sum_debit = self.cr.fetchone()[0] or 0.0 |
1725 | + return sum_debit |
1726 | + |
1727 | + |
1728 | + def _sum_credit_account(self, account, form): |
1729 | + self.cr.execute("SELECT sum(credit) "\ |
1730 | + "FROM account_move_line l "\ |
1731 | + "WHERE l.account_id = %s AND %s " % (account.id, self.query)) |
1732 | + sum_credit = self.cr.fetchone()[0] or 0.0 |
1733 | + return sum_credit |
1734 | + |
1735 | + |
1736 | + def _sum_balance_account(self, account, form): |
1737 | + # Balance from init fiscal year to last date given by the user |
1738 | + accounts = self.pool.get('account.account').read(self.cr, self.uid, [account.id], ['balance'], self.ctxfy) |
1739 | + sum_balance = accounts[0]['balance'] |
1740 | + return sum_balance |
1741 | + |
1742 | + |
1743 | + def _set_get_account_currency_code(self, account_id): |
1744 | + self.cr.execute("SELECT c.symbol as code "\ |
1745 | + "FROM res_currency c, account_account as ac "\ |
1746 | + "WHERE ac.id = %s AND ac.currency_id = c.id" % (account_id)) |
1747 | + result = self.cr.fetchone() |
1748 | + if result: |
1749 | + self.account_currency = result[0] |
1750 | + else: |
1751 | + self.account_currency = False |
1752 | + |
1753 | + |
1754 | + def _sum_currency_amount_account(self, account, form): |
1755 | + self._set_get_account_currency_code(account.id) |
1756 | + self.cr.execute("SELECT sum(l.amount_currency) "\ |
1757 | + "FROM account_move_line as l, res_currency as rc "\ |
1758 | + "WHERE l.currency_id = rc.id AND l.account_id= %s AND %s" % (account.id, self.query)) |
1759 | + total = self.cr.fetchone() |
1760 | + if self.account_currency: |
1761 | + return_field = str(total[0]) + self.account_currency |
1762 | + return return_field |
1763 | + else: |
1764 | + currency_total = self.tot_currency = 0.0 |
1765 | + return currency_total |
1766 | + |
1767 | + |
1768 | +report_sxw.report_sxw('report.account.general.ledger.cumulative.landscape2', 'account.account', 'addons/account_financial_report/report/general_ledger_landscape.rml', parser=general_ledger_landscape, header=False) |
1769 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1770 | |
1771 | === added file 'account_financial_report_web/report/rml_parse.py' |
1772 | --- account_financial_report_web/report/rml_parse.py 1970-01-01 00:00:00 +0000 |
1773 | +++ account_financial_report_web/report/rml_parse.py 2014-01-29 11:51:34 +0000 |
1774 | @@ -0,0 +1,172 @@ |
1775 | +# -*- encoding: utf-8 -*- |
1776 | +############################################################################## |
1777 | +# |
1778 | +# OpenERP, Open Source Management Solution |
1779 | +# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. |
1780 | +# Jordi Esteve <jesteve@zikzakmedia.com> |
1781 | +# $Id$ |
1782 | +# |
1783 | +# This program is free software: you can redistribute it and/or modify |
1784 | +# it under the terms of the GNU Affero General Public License as published by |
1785 | +# the Free Software Foundation, either version 3 of the License, or |
1786 | +# (at your option) any later version. |
1787 | +# |
1788 | +# This program is distributed in the hope that it will be useful, |
1789 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1790 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1791 | +# GNU Affero General Public License for more details. |
1792 | +# |
1793 | +# You should have received a copy of the GNU Affero General Public License |
1794 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1795 | +# |
1796 | +############################################################################## |
1797 | + |
1798 | +from report import report_sxw |
1799 | +import xml.dom.minidom |
1800 | +import os, time |
1801 | +import osv |
1802 | +import re |
1803 | +import tools |
1804 | +import pooler |
1805 | +import re |
1806 | +import sys |
1807 | + |
1808 | + |
1809 | +class rml_parse(report_sxw.rml_parse): |
1810 | + |
1811 | + def __init__(self, cr, uid, name, context): |
1812 | + super(rml_parse, self).__init__(cr, uid, name, context=None) |
1813 | + self.localcontext.update({ |
1814 | + 'comma_me': self.comma_me, |
1815 | + 'format_date': self._get_and_change_date_format_for_swiss, |
1816 | + 'strip_name' : self._strip_name, |
1817 | + 'explode_name' : self._explode_name, |
1818 | + }) |
1819 | + |
1820 | + def comma_me(self,amount): |
1821 | + if not amount: |
1822 | + amount = 0.0 |
1823 | + if type(amount) is float : |
1824 | + amount = str('%.2f'%amount) |
1825 | + else : |
1826 | + amount = str(amount) |
1827 | + if (amount == '0'): |
1828 | + return ' ' |
1829 | + orig = amount |
1830 | + new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount) |
1831 | + if orig == new: |
1832 | + return new |
1833 | + else: |
1834 | + return self.comma_me(new) |
1835 | + def _ellipsis(self, string, maxlen=100, ellipsis = '...'): |
1836 | + ellipsis = ellipsis or '' |
1837 | + try: |
1838 | + return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen] |
1839 | + except Exception, e: |
1840 | + return False |
1841 | + def _strip_name(self, name, maxlen=50): |
1842 | + return self._ellipsis(name, maxlen, '...') |
1843 | + |
1844 | + def _get_and_change_date_format_for_swiss (self,date_to_format): |
1845 | + date_formatted='' |
1846 | + if date_to_format: |
1847 | + date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y') |
1848 | + return date_formatted |
1849 | + |
1850 | + def _explode_name(self,chaine,length): |
1851 | + # We will test if the size is less then account |
1852 | + full_string = '' |
1853 | + if (len(str(chaine)) <= length): |
1854 | + return chaine |
1855 | + # |
1856 | + else: |
1857 | + chaine = unicode(chaine,'utf8').encode('iso-8859-1') |
1858 | + rup = 0 |
1859 | + for carac in chaine: |
1860 | + rup = rup + 1 |
1861 | + if rup == length: |
1862 | + full_string = full_string + '\n' |
1863 | + full_string = full_string + carac |
1864 | + rup = 0 |
1865 | + else: |
1866 | + full_string = full_string + carac |
1867 | + |
1868 | + return full_string |
1869 | + |
1870 | + def makeAscii(self,str): |
1871 | + try: |
1872 | + Stringer = str.encode("utf-8") |
1873 | + except UnicodeDecodeError: |
1874 | + try: |
1875 | + Stringer = str.encode("utf-16") |
1876 | + except UnicodeDecodeError: |
1877 | + Stringer = str |
1878 | + else: |
1879 | + return Stringer |
1880 | + else: |
1881 | + return Stringer |
1882 | + return Stringer |
1883 | + def explode_this(self,chaine,length): |
1884 | + #chaine = self.repair_string(chaine) |
1885 | + chaine = rstrip(chaine) |
1886 | + ast = list(chaine) |
1887 | + i = length |
1888 | + while i <= len(ast): |
1889 | + ast.insert(i,'\n') |
1890 | + i = i + length |
1891 | + chaine = str("".join(ast)) |
1892 | + return chaine |
1893 | + def repair_string(self,chaine): |
1894 | + ast = list(chaine) |
1895 | + UnicodeAst = [] |
1896 | + _previouslyfound = False |
1897 | + i = 0 |
1898 | + while i < len(ast): |
1899 | + elem = ast[i] |
1900 | + try: |
1901 | + Stringer = elem.encode("utf-8") |
1902 | + except UnicodeDecodeError: |
1903 | + to_reencode = elem + ast[i+1] |
1904 | + Good_char = to_reencode.decode('utf-8') |
1905 | + UnicodeAst.append(Good_char) |
1906 | + i += i +2 |
1907 | + else: |
1908 | + UnicodeAst.append(elem) |
1909 | + i += i + 1 |
1910 | + |
1911 | + |
1912 | + return "".join(UnicodeAst) |
1913 | + |
1914 | + def ReencodeAscii(self,str): |
1915 | + try: |
1916 | + Stringer = str.decode("ascii") |
1917 | + except UnicodeEncodeError: |
1918 | + return str.encode("ascii") |
1919 | + except UnicodeDecodeError: |
1920 | + return str.encode("ascii") |
1921 | + |
1922 | + else: |
1923 | + return Stringer |
1924 | + |
1925 | + |
1926 | + # def _add_header(self, node): |
1927 | + # rml_head = tools.file_open('specific_param/report/header/corporate_rml_header_ch.rml').read() |
1928 | + # head_dom = xml.dom.minidom.parseString(rml_head) |
1929 | + # #for frame in head_dom.getElementsByTagName('frame'): |
1930 | + # # frame.parentNode.removeChild(frame) |
1931 | + # node2 = head_dom.documentElement |
1932 | + # for tag in node2.childNodes: |
1933 | + # if tag.nodeType==tag.ELEMENT_NODE: |
1934 | + # found = self._find_node(node, tag.localName) |
1935 | + # # rml_frames = found.getElementsByTagName('frame') |
1936 | + # if found: |
1937 | + # if tag.hasAttribute('position') and (tag.getAttribute('position')=='inside'): |
1938 | + # found.appendChild(tag) |
1939 | + # else: |
1940 | + # found.parentNode.replaceChild(tag, found) |
1941 | + # # for frame in rml_frames: |
1942 | + # # tag.appendChild(frame) |
1943 | + # return True |
1944 | + |
1945 | + |
1946 | + |
1947 | |
1948 | === added directory 'account_financial_report_web/wizard' |
1949 | === added file 'account_financial_report_web/wizard/__init__.py' |
1950 | --- account_financial_report_web/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
1951 | +++ account_financial_report_web/wizard/__init__.py 2014-01-29 11:51:34 +0000 |
1952 | @@ -0,0 +1,23 @@ |
1953 | +# -*- encoding: utf-8 -*- |
1954 | +############################################################################## |
1955 | +# |
1956 | +# OpenERP, Open Source Management Solution |
1957 | +# Copyright (c) 2009 Factor Libre (http://factorlibre.com) All Rights Reserved. |
1958 | +# |
1959 | +# This program is free software: you can redistribute it and/or modify |
1960 | +# it under the terms of the GNU Affero General Public License as published by |
1961 | +# the Free Software Foundation, either version 3 of the License, or |
1962 | +# (at your option) any later version. |
1963 | +# |
1964 | +# This program is distributed in the hope that it will be useful, |
1965 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1966 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1967 | +# GNU Affero General Public License for more details. |
1968 | +# |
1969 | +# You should have received a copy of the GNU Affero General Public License |
1970 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1971 | +# |
1972 | +############################################################################## |
1973 | + |
1974 | +import wizard_account_balance_report |
1975 | + |
1976 | |
1977 | === added file 'account_financial_report_web/wizard/wizard_account_balance_report.py' |
1978 | --- account_financial_report_web/wizard/wizard_account_balance_report.py 1970-01-01 00:00:00 +0000 |
1979 | +++ account_financial_report_web/wizard/wizard_account_balance_report.py 2014-01-29 11:51:34 +0000 |
1980 | @@ -0,0 +1,244 @@ |
1981 | +# -*- encoding: utf-8 -*- |
1982 | +############################################################################## |
1983 | +# |
1984 | +# OpenERP, Open Source Management Solution |
1985 | +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
1986 | +# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. |
1987 | +# Jordi Esteve <jesteve@zikzakmedia.com> |
1988 | +# $Id$ |
1989 | +# |
1990 | +# This program is free software: you can redistribute it and/or modify |
1991 | +# it under the terms of the GNU Affero General Public License as published by |
1992 | +# the Free Software Foundation, either version 3 of the License, or |
1993 | +# (at your option) any later version. |
1994 | +# |
1995 | +# This program is distributed in the hope that it will be useful, |
1996 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1997 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1998 | +# GNU Affero General Public License for more details. |
1999 | +# |
2000 | +# You should have received a copy of the GNU Affero General Public License |
2001 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2002 | +# |
2003 | +############################################################################## |
2004 | + |
2005 | +import wizard |
2006 | +import pooler |
2007 | +import time |
2008 | +import report |
2009 | +from osv import osv, fields |
2010 | +from tools.translate import _ |
2011 | + |
2012 | +class fl_account_balance_full_report(osv.osv_memory): |
2013 | + |
2014 | + _name = 'fl.account.balance.full.report' |
2015 | + _columns = { |
2016 | + |
2017 | + 'company_id': fields.many2one('res.company','Company',required=True), |
2018 | + 'account_list':fields.many2many('account.account', 'balance_full_account_rel2', 'balance_id','account_id','Root accounts', required=True), |
2019 | + 'state':fields.selection((('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')), |
2020 | + 'Date/Period Filter'), |
2021 | + 'fiscalyear':fields.many2one('account.fiscalyear', 'Fiscal year', required=True, help='Keep empty to use all open fiscal years to compute the balance'), |
2022 | + 'periods':fields.many2many('account.period', 'balance_full_period_rel2', 'balance_id','period_id', 'Periods', help='All periods in the fiscal year if empty'), |
2023 | + 'display_account':fields.selection((('bal_all','All'),('bal_solde', 'With balance'),('bal_mouvement','With movements')),'Display accounts '), |
2024 | + 'display_account_level':fields.integer('Up to level', help='Display accounts up to this level (0 to show all)'), |
2025 | + 'date_from':fields.date('Start date',required=True), |
2026 | + 'date_to':fields.date('End date',required=True), |
2027 | + } |
2028 | + _defaults = { |
2029 | + 'date_from': lambda *a: time.strftime('%Y-%m-%d'), |
2030 | + 'date_to': lambda *a: time.strftime('%Y-%m-%d'), |
2031 | + 'state': lambda *a:'none', |
2032 | + 'display_account_level': lambda *a: 0, |
2033 | + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c), |
2034 | + 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid), |
2035 | + 'display_account': lambda *a:'bal_all', |
2036 | + } |
2037 | + |
2038 | + def onchange_company_id(self,cr,uid,ids,company_id,context=None): |
2039 | + if context is None: |
2040 | + context = {} |
2041 | + context['company_id']=company_id |
2042 | + res = {'value':{}} |
2043 | + |
2044 | + if not company_id: |
2045 | + return res |
2046 | + |
2047 | + cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id |
2048 | + fy_id = self.pool.get('account.fiscalyear').find(cr, uid,context=context) |
2049 | + res['value'].update({'fiscalyear':fy_id}) |
2050 | + res['value'].update({'account_list':[]}) |
2051 | + res['value'].update({'periods':[]}) |
2052 | + return res |
2053 | + |
2054 | + def _get_defaults(self, cr, uid, data, context=None): |
2055 | + if context is None: |
2056 | + context = {} |
2057 | + user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context) |
2058 | + if user.company_id: |
2059 | + company_id = user.company_id.id |
2060 | + else: |
2061 | + company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] |
2062 | + data['form']['company_id'] = company_id |
2063 | + fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear') |
2064 | + data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) |
2065 | + data['form']['context'] = context |
2066 | + return data['form'] |
2067 | + |
2068 | + |
2069 | + def _check_state(self, cr, uid, data, context=None): |
2070 | + |
2071 | + if context is None: |
2072 | + context = {} |
2073 | + if data['form']['state'] == 'bydate': |
2074 | + self._check_date(cr, uid, data, context) |
2075 | + return data['form'] |
2076 | + |
2077 | + def _check_date(self, cr, uid, data, context=None): |
2078 | + if context is None: |
2079 | + context = {} |
2080 | + |
2081 | + if data['form']['date_from'] > data['form']['date_to']: |
2082 | + raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial')) |
2083 | + |
2084 | + sql = """SELECT f.id, f.date_start, f.date_stop |
2085 | + FROM account_fiscalyear f |
2086 | + WHERE '%s' = f.id """%(data['form']['fiscalyear'][0]) |
2087 | + cr.execute(sql) |
2088 | + res = cr.dictfetchall() |
2089 | + |
2090 | + if res: |
2091 | + if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']): |
2092 | + raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop'])) |
2093 | + else: |
2094 | + return 'report' |
2095 | + else: |
2096 | + raise osv.except_osv(_('UserError'),'No existe periodo fiscal') |
2097 | + |
2098 | + def period_span(self, cr, uid, ids, fy_id, context=None): |
2099 | + if context is None: |
2100 | + context = {} |
2101 | + ap_obj = self.pool.get('account.period') |
2102 | + fy_id = fy_id and type(fy_id) in (list,tuple) and fy_id[0] or fy_id |
2103 | + if not ids: |
2104 | + #~ No hay periodos |
2105 | + return ap_obj.search(cr, uid, [('fiscalyear_id','=',fy_id),('special','=',False)],order='date_start asc') |
2106 | + |
2107 | + ap_brws = ap_obj.browse(cr, uid, ids, context=context) |
2108 | + date_start = min([period.date_start for period in ap_brws]) |
2109 | + date_stop = max([period.date_stop for period in ap_brws]) |
2110 | + return ap_obj.search(cr, uid, [('fiscalyear_id','=',fy_id),('special','=',False),('date_start','>=',date_start),('date_stop','<=',date_stop)],order='date_start asc') |
2111 | + |
2112 | + |
2113 | + def print_report(self, cr, uid, ids, data, context=None): |
2114 | + |
2115 | + if context is None: |
2116 | + context = {} |
2117 | + |
2118 | + data = {} |
2119 | + data['ids'] = context.get('active_ids', []) |
2120 | + data['model'] = context.get('active_model', 'ir.ui.menu') |
2121 | + data['form'] = self.read(cr, uid, ids[0]) |
2122 | + if data['form']['state'] == 'byperiod': |
2123 | + del data['form']['date_from'] |
2124 | + del data['form']['date_to'] |
2125 | + |
2126 | + data['form']['periods'] = self.period_span(cr, uid, data['form']['periods'], data['form']['fiscalyear']) |
2127 | + |
2128 | + elif data['form']['state'] == 'bydate': |
2129 | + self._check_date(cr, uid, data) |
2130 | + del data['form']['periods'] |
2131 | + elif data['form']['state'] == 'none': |
2132 | + del data['form']['date_from'] |
2133 | + del data['form']['date_to'] |
2134 | + del data['form']['periods'] |
2135 | + else: |
2136 | + self._check_date(cr, uid, data) |
2137 | + lis2 = str(data['form']['periods']).replace("[","(").replace("]",")") |
2138 | + sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin |
2139 | + from account_period p |
2140 | + where p.id in %s"""%lis2 |
2141 | + cr.execute(sqlmm) |
2142 | + minmax = cr.dictfetchall() |
2143 | + if minmax: |
2144 | + if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']): |
2145 | + raise osv.except_osv(_('Error !'),_('La interseccion entre el periodo y fecha es vacio')) |
2146 | + |
2147 | + return {'type': 'ir.actions.report.xml', 'report_name': 'account.balance.full2', 'datas': data} |
2148 | + |
2149 | +fl_account_balance_full_report() |
2150 | + |
2151 | +class fl_account_general_ledger_cumulative_report(osv.osv_memory): |
2152 | + |
2153 | + |
2154 | + _name = 'fl.account.general.ledger.cumulative.report' |
2155 | + _columns = { |
2156 | + 'account_list': fields.many2many('account.account', 'general_ledger_cumulative_rel_2', 'ledger_cumulative_id', 'account_id', 'Account'), |
2157 | + 'company_id': fields.many2one('res.company', 'Company'), |
2158 | + 'state': fields.selection((('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')),'Date/Period Filter'), |
2159 | + 'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal year', help='Keep empty for all open fiscal year'), |
2160 | + 'periods':fields.many2many('account.period', 'general_ledger_cumulative_period_rel2', 'ledger_cumulative_id','period_id', 'Periods', help='All periods in the fiscal year if empty'), |
2161 | + |
2162 | + 'sortbydate':fields.selection((('sort_date','Date'),('sort_mvt','Movement')),'Sort by'), |
2163 | + 'display_account': fields.selection((('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')), 'Display accounts'), |
2164 | + |
2165 | + 'landscape':fields.boolean('Landscape Mode'), |
2166 | + 'initial_balance':fields.boolean('Show initial balances'), |
2167 | + 'amount_currency':fields.boolean('With Currency'), |
2168 | + 'date_from':fields.date('Start date',required=True), |
2169 | + 'date_to':fields.date('End date',required=True), |
2170 | + 'states': fields.selection((('account_selection','Account Selection'),('checktype','Check Type')), 'State'), |
2171 | + |
2172 | + |
2173 | + |
2174 | + } |
2175 | + |
2176 | + def _init_states(self, cr, uid, context=None): |
2177 | + return 'account_selection' |
2178 | + |
2179 | + def step1(self, cr, uid, ids, context): |
2180 | + data={'states': 'checktype'} |
2181 | + user=self.pool.get('res.users').browse(cr, uid, uid, context=context) |
2182 | + if user.company_id: |
2183 | + company_id = user.company_id.id |
2184 | + else: |
2185 | + company_id = self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] |
2186 | + data['company_id']=company_id |
2187 | + fiscalyear_obj = self.pool.get('account.fiscalyear') |
2188 | + data['fiscalyear'] = fiscalyear_obj.find(cr, uid) |
2189 | + self.write(cr, uid, ids, data) |
2190 | + |
2191 | + def prints(self, cr, uid, ids, context): |
2192 | + |
2193 | + if context is None: |
2194 | + context = {} |
2195 | + |
2196 | + data = {} |
2197 | + data['ids'] = context.get('active_ids', []) |
2198 | + data['model'] = context.get('active_model', 'ir.ui.menu') |
2199 | + data['form'] = self.read(cr, uid, ids[0]) |
2200 | + if data['form']['state'] == 'bydate': |
2201 | + sql = """SELECT f.id, f.date_start, f.date_stop |
2202 | + FROM account_fiscalyear f |
2203 | + WHERE '%s' between f.date_start and f.date_stop """ % (data['form']['date_from']) |
2204 | + cr.execute(sql) |
2205 | + res = cr.dictfetchall() |
2206 | + if res: |
2207 | + if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): |
2208 | + raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (str(res[0]['date_start']), str(res[0]['date_stop']))) |
2209 | + else: |
2210 | + raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year')) |
2211 | + if data['form']['landscape']== True: |
2212 | + return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger.cumulative.landscape2', 'datas': data} |
2213 | + else: |
2214 | + return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger.cumulative2', 'datas': data} |
2215 | + |
2216 | + _defaults = { |
2217 | + 'date_from': lambda *a: time.strftime('%Y-01-01'), |
2218 | + 'date_to': lambda *a: time.strftime('%Y-%m-%d'), |
2219 | + 'states': lambda self,cr,uid,c: self._init_states(cr, uid, context=c), |
2220 | + 'state' : lambda *a:'none', |
2221 | + } |
2222 | + |
2223 | +fl_account_general_ledger_cumulative_report() |
2224 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
2225 | |
2226 | === added directory 'report_cumulative_general_ledger_xls' |
2227 | === added file 'report_cumulative_general_ledger_xls/__init__.py' |
2228 | --- report_cumulative_general_ledger_xls/__init__.py 1970-01-01 00:00:00 +0000 |
2229 | +++ report_cumulative_general_ledger_xls/__init__.py 2014-01-29 11:51:34 +0000 |
2230 | @@ -0,0 +1,29 @@ |
2231 | +############################################################################## |
2232 | +# |
2233 | +# Copyright (c) 2014 Factor Libre S.L. (http://www.factorlibre.com) All Rights Reserved. |
2234 | +# |
2235 | +# Developer Rafael Valle |
2236 | +# WARNING: This program as such is intended to be used by professional |
2237 | +# programmers who take the whole responsability of assessing all potential |
2238 | +# consequences resulting from its eventual inadequacies and bugs |
2239 | +# End users who are looking for a ready-to-use solution with commercial |
2240 | +# garantees and support are strongly adviced to contract a Free Software |
2241 | +# Service Company |
2242 | +# |
2243 | +# This program is Free Software; you can redistribute it and/or |
2244 | +# modify it under the terms of the GNU General Public License |
2245 | +# as published by the Free Software Foundation; either version 2 |
2246 | +# of the License, or (at your option) any later version. |
2247 | +# |
2248 | +# This program is distributed in the hope that it will be useful, |
2249 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2250 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2251 | +# GNU General Public License for more details. |
2252 | +# |
2253 | +# You should have received a copy of the GNU General Public License |
2254 | +# along with this program; if not, write to the Free Software |
2255 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
2256 | +# |
2257 | +############################################################################## |
2258 | + |
2259 | +import wizard |
2260 | |
2261 | === added file 'report_cumulative_general_ledger_xls/__openerp__.py' |
2262 | --- report_cumulative_general_ledger_xls/__openerp__.py 1970-01-01 00:00:00 +0000 |
2263 | +++ report_cumulative_general_ledger_xls/__openerp__.py 2014-01-29 11:51:34 +0000 |
2264 | @@ -0,0 +1,38 @@ |
2265 | +# -*- coding: utf-8 -*- |
2266 | +############################################################################## |
2267 | +# |
2268 | +# OpenERP, Open Source Management Solution |
2269 | +# Copyright (C) 2014 Factor Libre S.L (<http://www.factorlibre.com>). |
2270 | +# Developer Rafael Valle |
2271 | +# This program is free software: you can redistribute it and/or modify |
2272 | +# it under the terms of the GNU Affero General Public License as |
2273 | +# published by the Free Software Foundation, either version 3 of the |
2274 | +# License, or (at your option) any later version. |
2275 | +# |
2276 | +# This program is distributed in the hope that it will be useful, |
2277 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2278 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2279 | +# GNU Affero General Public License for more details. |
2280 | +# |
2281 | +# You should have received a copy of the GNU Affero General Public License |
2282 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2283 | +# |
2284 | +############################################################################## |
2285 | + |
2286 | +{ |
2287 | + "name" : "Report cumulative general ledger xls", |
2288 | + "description": """Allows get cumulative general ledger in xls""", |
2289 | + "version" : "1.0", |
2290 | + "author" : "Factor Libre S.L", |
2291 | + "category" : "Accounting", |
2292 | + "module": "", |
2293 | + "website": "http://www.factorlibre.com/", |
2294 | + "depends" : ["account","account_financial_report","account_financial_report_web"], |
2295 | + "init_xml" : [], |
2296 | + "update_xml" : [ |
2297 | + "wizard/cumulative_general_ledger_xls_view.xml", |
2298 | + ], |
2299 | + "demo_xml" : [], |
2300 | + "active": False, |
2301 | + "installable": True |
2302 | +} |
2303 | |
2304 | === added directory 'report_cumulative_general_ledger_xls/i18n' |
2305 | === added file 'report_cumulative_general_ledger_xls/i18n/es.mo' |
2306 | Binary files report_cumulative_general_ledger_xls/i18n/es.mo 1970-01-01 00:00:00 +0000 and report_cumulative_general_ledger_xls/i18n/es.mo 2014-01-29 11:51:34 +0000 differ |
2307 | === added file 'report_cumulative_general_ledger_xls/i18n/es.po' |
2308 | --- report_cumulative_general_ledger_xls/i18n/es.po 1970-01-01 00:00:00 +0000 |
2309 | +++ report_cumulative_general_ledger_xls/i18n/es.po 2014-01-29 11:51:34 +0000 |
2310 | @@ -0,0 +1,72 @@ |
2311 | +# Translation of OpenERP Server. |
2312 | +# This file contains the translation of the following modules: |
2313 | +# * report_cumulative_general_ledger_xls |
2314 | +# |
2315 | +msgid "" |
2316 | +msgstr "" |
2317 | +"Project-Id-Version: OpenERP Server 6.1-20130627-233424\n" |
2318 | +"Report-Msgid-Bugs-To: \n" |
2319 | +"POT-Creation-Date: 2014-01-29 10:42+0000\n" |
2320 | +"PO-Revision-Date: 2014-01-29 11:44+0100\n" |
2321 | +"Last-Translator: <>\n" |
2322 | +"Language-Team: \n" |
2323 | +"MIME-Version: 1.0\n" |
2324 | +"Content-Type: text/plain; charset=UTF-8\n" |
2325 | +"Content-Transfer-Encoding: 8bit\n" |
2326 | +"Plural-Forms: \n" |
2327 | +"X-Generator: Poedit 1.5.4\n" |
2328 | + |
2329 | +#. module: report_cumulative_general_ledger_xls |
2330 | +#: field:fl.account.general.ledger.cumulative.report,export_file:0 |
2331 | +msgid "Export File" |
2332 | +msgstr "Fichero generado" |
2333 | + |
2334 | +#. module: report_cumulative_general_ledger_xls |
2335 | +#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:231 |
2336 | +#, python-format |
2337 | +msgid "CI: " |
2338 | +msgstr "CI: " |
2339 | + |
2340 | +#. module: report_cumulative_general_ledger_xls |
2341 | +#: model:ir.model,name:report_cumulative_general_ledger_xls.model_fl_account_general_ledger_cumulative_report |
2342 | +msgid "fl.account.general.ledger.cumulative.report" |
2343 | +msgstr "fl.account.general.ledger.cumulative.report" |
2344 | + |
2345 | +#. module: report_cumulative_general_ledger_xls |
2346 | +#: field:fl.account.general.ledger.cumulative.report,name:0 |
2347 | +msgid "Filename" |
2348 | +msgstr "Nombre de Fichero" |
2349 | + |
2350 | +#. module: report_cumulative_general_ledger_xls |
2351 | +#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:233 |
2352 | +#, python-format |
2353 | +msgid "OR: " |
2354 | +msgstr "OR: " |
2355 | + |
2356 | +#. module: report_cumulative_general_ledger_xls |
2357 | +#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:234 |
2358 | +#, python-format |
2359 | +msgid "SR: " |
2360 | +msgstr "SR: " |
2361 | + |
2362 | +#. module: report_cumulative_general_ledger_xls |
2363 | +#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:232 |
2364 | +#, python-format |
2365 | +msgid "SI: " |
2366 | +msgstr "SI: " |
2367 | + |
2368 | +#. module: report_cumulative_general_ledger_xls |
2369 | +#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:293 |
2370 | +#, python-format |
2371 | +msgid "Initial balance" |
2372 | +msgstr "Balance Inicial" |
2373 | + |
2374 | +#. module: report_cumulative_general_ledger_xls |
2375 | +#: view:fl.account.general.ledger.cumulative.report:0 |
2376 | +msgid "XLS" |
2377 | +msgstr "XLS" |
2378 | + |
2379 | +#. module: report_cumulative_general_ledger_xls |
2380 | +#: view:fl.account.general.ledger.cumulative.report:0 |
2381 | +msgid "Export XLS" |
2382 | +msgstr "Generar XLS" |
2383 | |
2384 | === added directory 'report_cumulative_general_ledger_xls/wizard' |
2385 | === added file 'report_cumulative_general_ledger_xls/wizard/__init__.py' |
2386 | --- report_cumulative_general_ledger_xls/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
2387 | +++ report_cumulative_general_ledger_xls/wizard/__init__.py 2014-01-29 11:51:34 +0000 |
2388 | @@ -0,0 +1,27 @@ |
2389 | +# -*- coding: utf-8 -*- |
2390 | +############################################################################## |
2391 | +# |
2392 | +# OpenERP, Open Source Management Solution |
2393 | +# Copyright (C) 2014 Rafael Valle (Factor Libre S.L) (<http://factorlibre.com>). |
2394 | +# |
2395 | +# This program is free software: you can redistribute it and/or modify |
2396 | +# it under the terms of the GNU Affero General Public License as |
2397 | +# published by the Free Software Foundation, either version 3 of the |
2398 | +# License, or (at your option) any later version. |
2399 | +# |
2400 | +# This program is distributed in the hope that it will be useful, |
2401 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2402 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2403 | +# GNU Affero General Public License for more details. |
2404 | +# |
2405 | +# You should have received a copy of the GNU Affero General Public License |
2406 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2407 | +# |
2408 | +############################################################################## |
2409 | + |
2410 | +import cumulative_general_ledger |
2411 | + |
2412 | + |
2413 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
2414 | + |
2415 | + |
2416 | |
2417 | === added file 'report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py' |
2418 | --- report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py 1970-01-01 00:00:00 +0000 |
2419 | +++ report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py 2014-01-29 11:51:34 +0000 |
2420 | @@ -0,0 +1,434 @@ |
2421 | +# -*- coding: utf-8 -*- |
2422 | +############################################################################## |
2423 | +# |
2424 | +# OpenERP, Open Source Management Solution |
2425 | +# Copyright (C) 2013 Factor Libre. |
2426 | +# Developer Rafael Valle |
2427 | +# |
2428 | +# This program is free software: you can redistribute it and/or modify |
2429 | +# it under the terms of the GNU Affero General Public License as |
2430 | +# published by the Free Software Foundation, either version 3 of the |
2431 | +# License, or (at your option) any later version. |
2432 | +# |
2433 | +# This program is distributed in the hope that it will be useful, |
2434 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2435 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2436 | +# GNU Affero General Public License for more details. |
2437 | +# |
2438 | +# You should have received a copy of the GNU Affero General Public License |
2439 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2440 | +# |
2441 | +############################################################################## |
2442 | + |
2443 | +import time, dateutil, dateutil.tz |
2444 | +from datetime import date, datetime |
2445 | + |
2446 | +import cStringIO |
2447 | +import base64 |
2448 | +from xlwt import * |
2449 | +import pooler |
2450 | +from osv import osv, fields |
2451 | +from tools.translate import _ |
2452 | +import logging |
2453 | +_logger = logging.getLogger(__name__) |
2454 | + |
2455 | +class fl_account_general_ledger_cumulative_report(osv.osv_memory): |
2456 | + _inherit = "fl.account.general.ledger.cumulative.report" |
2457 | + |
2458 | + |
2459 | + |
2460 | + _columns = { |
2461 | + 'name': fields.char('Filename', size=64, readonly=True), |
2462 | + 'export_file': fields.binary('Export File', readonly=True), |
2463 | + } |
2464 | + |
2465 | + |
2466 | + |
2467 | + |
2468 | + |
2469 | + |
2470 | + def get_fiscalyear(self, cr, uid, form): |
2471 | + res=[] |
2472 | + if form.has_key('fiscalyear'): |
2473 | + fisc_id = form['fiscalyear'][0] |
2474 | + if not (fisc_id): |
2475 | + return '' |
2476 | + cr.execute("SELECT name FROM account_fiscalyear WHERE id = %s" , (int(fisc_id),)) |
2477 | + res=cr.fetchone() |
2478 | + return res and res[0] or '' |
2479 | + |
2480 | + |
2481 | + def get_periods(self, cr, uid, form): |
2482 | + result='' |
2483 | + if form.has_key('periods') and form['periods']: |
2484 | + period_ids = ",".join([str(x) for x in form['periods'] if x]) |
2485 | + self.cr.execute("SELECT name FROM account_period WHERE id in (%s)" % (period_ids)) |
2486 | + res = self.cr.fetchall() |
2487 | + len_res = len(res) |
2488 | + for r in res: |
2489 | + if (r == res[len_res-1]): |
2490 | + result+=r[0]+". " |
2491 | + else: |
2492 | + result+=r[0]+", " |
2493 | + elif form.has_key('date_from') and form.has_key('date_to'): |
2494 | + result = form['date_from'] + ' - ' + form['date_to'] + ' ' |
2495 | + else: |
2496 | + fy_obj = self.pool.get('account.fiscalyear').browse(cr,uid,form['fiscalyear'][0]) |
2497 | + res = fy_obj.period_ids |
2498 | + len_res = len(res) |
2499 | + for r in res: |
2500 | + if r == res[len_res-1]: |
2501 | + result+=r.name+". " |
2502 | + else: |
2503 | + result+=r.name+", " |
2504 | + |
2505 | + return str(result and result[:-1]) or '' |
2506 | + |
2507 | + |
2508 | + |
2509 | + def _sum_balance_account(self, cr, uid, account, form, ctxfy): |
2510 | + # Balance from init fiscal year to last date given by the user |
2511 | + accounts = self.pool.get('account.account').read(cr, uid, [account.id], ['balance'], ctxfy) |
2512 | + sum_balance = accounts[0]['balance'] |
2513 | + return sum_balance |
2514 | + |
2515 | + |
2516 | + def _sum_debit_account(self, cr, uid, account, form, query): |
2517 | + cr.execute("SELECT sum(debit) "\ |
2518 | + "FROM account_move_line l "\ |
2519 | + "WHERE l.account_id = %s AND %s " % (account.id, query)) |
2520 | + sum_debit = cr.fetchone()[0] or 0.0 |
2521 | + return sum_debit |
2522 | + |
2523 | + |
2524 | + def _sum_credit_account(self, cr, uid, account, form, query): |
2525 | + cr.execute("SELECT sum(credit) "\ |
2526 | + "FROM account_move_line l "\ |
2527 | + "WHERE l.account_id = %s AND %s " % (account.id, query)) |
2528 | + sum_credit = cr.fetchone()[0] or 0.0 |
2529 | + return sum_credit |
2530 | + |
2531 | + |
2532 | + def _calc_contrepartie(self, cr, uid, ids, context={}): |
2533 | + result = {} |
2534 | + #for id in ids: |
2535 | + # result.setdefault(id, False) |
2536 | + for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context): |
2537 | + # For avoid long text in the field we will limit it to 5 lines |
2538 | + # |
2539 | + result[account_line.id] = ' ' |
2540 | + num_id_move = str(account_line.move_id.id) |
2541 | + num_id_line = str(account_line.id) |
2542 | + account_id = str(account_line.account_id.id) |
2543 | + # search the basic account |
2544 | + # We have the account ID we will search all account move line from now until this time |
2545 | + # We are in the case of we are on the top of the account move Line |
2546 | + cr.execute("SELECT distinct(ac.code) as code_rest,ac.name as name_rest "\ |
2547 | + "FROM account_account AS ac, account_move_line mv "\ |
2548 | + "WHERE ac.id = mv.account_id and mv.move_id = " + num_id_move + " and mv.account_id <> " + account_id ) |
2549 | + res_mv = cr.dictfetchall() |
2550 | + # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line |
2551 | + if (len(res_mv) >=1): |
2552 | + concat = '' |
2553 | + rup_id = 0 |
2554 | + for move_rest in res_mv: |
2555 | + concat = concat + move_rest['code_rest'] + '|' |
2556 | + result[account_line.id] = concat |
2557 | + if rup_id >5: |
2558 | + # we need to stop the computing and to escape but before we will add "..." |
2559 | + result[account_line.id] = concat + '...' |
2560 | + break |
2561 | + rup_id+=1 |
2562 | + return result |
2563 | + |
2564 | + def get_children_accounts(self, cr, uid, account, form, query, ctx, context=None): |
2565 | + balance_accounts = {} |
2566 | + move_line_obj = self.pool.get('account.move.line') |
2567 | + account_obj = self.pool.get('account.account') |
2568 | + invoice_obj = self.pool.get('account.invoice') |
2569 | + child_ids = account_obj.search(cr, uid, [('parent_id', 'child_of', form['account_list'])]) |
2570 | + res = [] |
2571 | + ctx = ctx.copy() |
2572 | + if account and account.child_consol_ids: # add ids of consolidated childs also of selected account |
2573 | + ctx['consolidate_childs'] = True |
2574 | + ctx['account_id'] = account.id |
2575 | + ids_acc = account_obj.search(cr, uid,[('parent_id', 'child_of', [account.id])], context=ctx) |
2576 | + for child_id in ids_acc: |
2577 | + child_account = account_obj.browse(cr, uid, child_id) |
2578 | + balance_account = self._sum_balance_account( cr, uid, child_account, form, {}) |
2579 | + balance_accounts[child_account.id] = balance_account |
2580 | + if form['display_account'] == 'bal_mouvement': |
2581 | + if child_account.type != 'view' \ |
2582 | + and len(move_line_obj.search(cr, uid, |
2583 | + [('account_id','=',child_account.id)], |
2584 | + context=ctx)) <> 0 : |
2585 | + res.append(child_account) |
2586 | + elif form['display_account'] == 'bal_solde': |
2587 | + if child_account.type != 'view' \ |
2588 | + and len(move_line_obj.search(cr, uid, |
2589 | + [('account_id','=',child_account.id)], |
2590 | + context=ctx)) <> 0 : |
2591 | + if balance_account <> 0.0: |
2592 | + res.append(child_account) |
2593 | + else: |
2594 | + if child_account.type != 'view' \ |
2595 | + and len(move_line_obj.search(cr, uid, |
2596 | + [('account_id','>=',child_account.id)], |
2597 | + context=ctx)) <> 0 : |
2598 | + res.append(child_account) |
2599 | + ## |
2600 | + if not len(res): |
2601 | + return [account] |
2602 | + else: |
2603 | + ## We will now compute initial balance |
2604 | + for move in res: |
2605 | + sql_balance_init = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit "\ |
2606 | + "FROM account_move_line l "\ |
2607 | + "WHERE l.account_id = " + str(move.id) + " AND %s" % (query) |
2608 | + cr.execute(sql_balance_init) |
2609 | + resultat = cr.dictfetchall() |
2610 | + if resultat[0] : |
2611 | + if resultat[0]['sum_debit'] == None: |
2612 | + sum_debit = 0 |
2613 | + else: |
2614 | + sum_debit = resultat[0]['sum_debit'] |
2615 | + if resultat[0]['sum_credit'] == None: |
2616 | + sum_credit = 0 |
2617 | + else: |
2618 | + sum_credit = resultat[0]['sum_credit'] |
2619 | + |
2620 | + move.init_credit = sum_credit |
2621 | + move.init_debit = sum_debit |
2622 | + else: |
2623 | + move.init_credit = 0 |
2624 | + move.init_debit = 0 |
2625 | + return res |
2626 | + |
2627 | + |
2628 | + |
2629 | + def lines(self, cr, uid, account, form, query, ctxfy): |
2630 | + tot_currency = 0.0 |
2631 | + date_min = period_min = False |
2632 | + date_min = form['date_from'] |
2633 | + |
2634 | + #dates |
2635 | + if not period_min: |
2636 | + min_date = date_min |
2637 | + elif not date_min: |
2638 | + min_date = period_min |
2639 | + else: |
2640 | + # If period and date are given, the maximum of the min dates is choosed |
2641 | + if period_min < date_min: |
2642 | + min_date = date_min |
2643 | + else: |
2644 | + min_date = period_min |
2645 | + |
2646 | + |
2647 | + |
2648 | + |
2649 | + print query |
2650 | + inv_types = { |
2651 | + 'out_invoice': _('CI: '), |
2652 | + 'in_invoice': _('SI: '), |
2653 | + 'out_refund': _('OR: '), |
2654 | + 'in_refund': _('SR: '), |
2655 | + } |
2656 | + |
2657 | + if form['sortbydate'] == 'sort_date': |
2658 | + sorttag = 'l.date' |
2659 | + else: |
2660 | + sorttag = 'j.code' |
2661 | + sql = """ |
2662 | + SELECT l.id, l.date, j.code, c.symbol AS currency_code, l.amount_currency, l.ref, l.name , l.debit, l.credit, l.period_id |
2663 | + FROM account_move_line as l |
2664 | + LEFT JOIN res_currency c on (l.currency_id=c.id) |
2665 | + JOIN account_journal j on (l.journal_id=j.id) |
2666 | + AND account_id = %%s |
2667 | + AND %s |
2668 | + ORDER by %s""" % (query, sorttag) |
2669 | + cr.execute(sql % account.id) |
2670 | + |
2671 | + res = cr.dictfetchall() |
2672 | + move_line_obj = self.pool.get('account.move.line') |
2673 | + account_obj = self.pool.get('account.account') |
2674 | + invoice_obj = self.pool.get('account.invoice') |
2675 | + |
2676 | + # Balance from init fiscal year to last date given by the user |
2677 | + accounts = account_obj.read(cr, uid, [account.id], ['balance'], ctxfy) |
2678 | + sum = accounts[0]['balance'] |
2679 | + |
2680 | + for l in reversed(res): |
2681 | + line = move_line_obj.browse(cr, uid, l['id']) |
2682 | + l['move'] = line.move_id.name_split |
2683 | + cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id)) |
2684 | + tmpres = cr.dictfetchall() |
2685 | + if len(tmpres) > 0 : |
2686 | + inv = invoice_obj.browse(cr, uid, tmpres[0]['id']) |
2687 | + l['ref'] = inv_types[inv.type] + ': '+str(inv.number) |
2688 | + if line.partner_id : |
2689 | + l['partner'] = line.partner_id.name |
2690 | + else : |
2691 | + l['partner'] = '' |
2692 | + l['line_corresp'] = self._calc_contrepartie(cr,uid,[l['id']])[l['id']] |
2693 | + |
2694 | + # Cumulative balance update |
2695 | + l['progress'] = sum |
2696 | + sum = sum - l['debit'] + l ['credit'] |
2697 | + |
2698 | + # Modification of currency amount |
2699 | + if (l['credit'] > 0): |
2700 | + if l['amount_currency'] != None: |
2701 | + l['amount_currency'] = abs(l['amount_currency']) * -1 |
2702 | + if l['amount_currency'] != None: |
2703 | + tot_currency = tot_currency + l['amount_currency'] |
2704 | + |
2705 | + decimal_precision_obj = self.pool.get('decimal.precision') |
2706 | + ids = decimal_precision_obj.search(cr, uid, [('name', '=', 'Account')]) |
2707 | + digits = decimal_precision_obj.browse(cr, uid, ids)[0].digits |
2708 | + |
2709 | + #if abs(sum) > 10**-int(config['price_accuracy']) and form['initial_balance']: |
2710 | + if round(sum,digits) <> 0.0 and form['initial_balance']: |
2711 | + res.insert(0, { |
2712 | + 'date': self.min_date, |
2713 | + 'name': _('Initial balance'), |
2714 | + 'progress': sum, |
2715 | + 'partner': '', |
2716 | + 'move': '', |
2717 | + 'ref': '', |
2718 | + 'debit': '', |
2719 | + 'credit': '', |
2720 | + 'amount_currency': '', |
2721 | + 'currency_code': '', |
2722 | + 'code': '', |
2723 | + 'line_corresp': '', |
2724 | + }) |
2725 | + |
2726 | + return res |
2727 | + |
2728 | + |
2729 | + |
2730 | + |
2731 | + def get_report_file_xls(self, cr, uid, ids, context=None): |
2732 | + |
2733 | + if context is None: |
2734 | + context = {} |
2735 | + |
2736 | + data=self.prints(cr, uid, ids, context) |
2737 | + print data |
2738 | + |
2739 | + |
2740 | + #vals context |
2741 | + ctx2 = data['datas']['form'].get('used_context',{}).copy() |
2742 | + tot_currency = 0.0 |
2743 | + sortby = data['datas']['form'].get('sortby', 'sort_date') |
2744 | + |
2745 | + ctx = context.copy() |
2746 | + if 'fiscalyear' in data['datas']['form'] and data['datas']['form']['fiscalyear']: |
2747 | + ctx['fiscalyear'] = data['datas']['form']['fiscalyear'][0] |
2748 | + if data['datas']['form']['state'] in ['byperiod', 'all']: |
2749 | + ctx['periods'] = data['datas']['form']['periods'] |
2750 | + if data['datas']['form']['state'] in ['bydate', 'all']: |
2751 | + ctx['date_from'] = data['datas']['form']['date_from'] |
2752 | + ctx['date_to'] = data['datas']['form']['date_to'] |
2753 | + if 'periods' not in ctx: |
2754 | + ctx['periods'] = [] |
2755 | + ctx = ctx |
2756 | + |
2757 | + ctxfy = ctx.copy() |
2758 | + ctxfy['periods'] = ctx['periods'][:] |
2759 | + |
2760 | + #----------------------------------------- |
2761 | + |
2762 | + query = self.pool.get('account.move.line')._query_get(cr, uid, context=ctx) |
2763 | + |
2764 | + |
2765 | + user = self.pool.get('res.users').browse(cr, uid, uid, context = context) |
2766 | + |
2767 | + user_tz = dateutil.tz.gettz(user.context_tz) |
2768 | + utc_tz = dateutil.tz.tzutc() |
2769 | + |
2770 | + |
2771 | + excel_temp = cStringIO.StringIO() |
2772 | + w = Workbook(encoding='utf-8', style_compression=2) |
2773 | + ws = w.add_sheet('Hoja 1') |
2774 | + |
2775 | + #styles |
2776 | + style_headers1 = XFStyle() |
2777 | + # font |
2778 | + font = Font() |
2779 | + font.bold = True |
2780 | + style_headers1.font = font |
2781 | + # borders |
2782 | + borders = Borders() |
2783 | + borders.bottom = Borders.DASHED |
2784 | + style_headers1.borders = borders |
2785 | + |
2786 | + style_bold = XFStyle() |
2787 | + # font |
2788 | + font = Font() |
2789 | + font.bold = True |
2790 | + style_bold.font = font |
2791 | + |
2792 | + |
2793 | + # Header definition |
2794 | + ws.write_merge(0, 0, 0, 11,'LIBRO MAYOR ACUMULADO',style=style_headers1) |
2795 | + |
2796 | + |
2797 | + #Main Headers |
2798 | + ws.write(1,0,'Año Fiscal', style=style_headers1) |
2799 | + ws.write(2,0,'Periodos', style=style_headers1) |
2800 | + |
2801 | + |
2802 | + |
2803 | + ws.write(1,1,self.get_fiscalyear(cr,uid,data['datas']['form'])) |
2804 | + ws.write(2,1,self.get_periods(cr,uid,data['datas']['form'])) |
2805 | + |
2806 | + |
2807 | + #Table headers |
2808 | + |
2809 | + ws.write(6,0,'Fecha', style=style_headers1) |
2810 | + ws.write(6,1,'Asiento', style=style_headers1) |
2811 | + ws.write(6,2,'Empresa', style=style_headers1) |
2812 | + ws.write(6,3,'Ref', style=style_headers1) |
2813 | + ws.write(6,4,'Debe', style=style_headers1) |
2814 | + ws.write(6,5,'Haber', style=style_headers1) |
2815 | + ws.write(6,6,'Balance', style=style_headers1) |
2816 | + |
2817 | + |
2818 | + row=7 |
2819 | + #Children accounts |
2820 | + |
2821 | + for account_id in data['datas']['form']['account_list']: |
2822 | + acc_obj=self.pool.get('account.account').browse(cr,uid,account_id) |
2823 | + for a in self.get_children_accounts(cr, uid, acc_obj, data['datas']['form'], query, ctx, context): |
2824 | + ws.write(row,0,a.code+' '+a.name, style=style_bold) |
2825 | + ws.write(row,4,self._sum_debit_account(cr, uid, a, data['datas']['form'], query), style=style_bold) |
2826 | + ws.write(row,5,self._sum_credit_account(cr, uid, a, data['datas']['form'], query), style=style_bold) |
2827 | + ws.write(row,6,self._sum_balance_account( cr, uid, a, data['datas']['form'], ctxfy), style=style_bold) |
2828 | + row=row+1 |
2829 | + |
2830 | + #lines children |
2831 | + for a_line in self.lines(cr, uid, a, data['datas']['form'], query, ctxfy): |
2832 | + |
2833 | + #format date |
2834 | + ldated=datetime.strptime(a_line['date'], '%Y-%m-%d') |
2835 | + |
2836 | + ws.write(row,0,ldated.strftime('%d/%m/%Y')) |
2837 | + ws.write(row,1,a_line['move']) |
2838 | + ws.write(row,2,a_line['partner']) |
2839 | + ws.write(row,3,a_line['ref']) |
2840 | + ws.write(row,4,a_line['debit']) |
2841 | + ws.write(row,5,a_line['credit']) |
2842 | + ws.write(row,6,a_line['progress']) |
2843 | + row=row+1 |
2844 | + |
2845 | + w.save(excel_temp) |
2846 | + out=base64.encodestring(excel_temp.getvalue()) |
2847 | + excel_temp.close() |
2848 | + file_time = datetime.now(user_tz).strftime('%Y-%m-%d_%H%M') |
2849 | + |
2850 | + |
2851 | + return self.write(cr, uid, ids, { 'export_file': out, 'name': 'Libro_Mayor_Acumulado_%s.xls' % (file_time)}) |
2852 | + |
2853 | +fl_account_general_ledger_cumulative_report() |
2854 | + |
2855 | |
2856 | === added file 'report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger_xls_view.xml' |
2857 | --- report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger_xls_view.xml 1970-01-01 00:00:00 +0000 |
2858 | +++ report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger_xls_view.xml 2014-01-29 11:51:34 +0000 |
2859 | @@ -0,0 +1,26 @@ |
2860 | +<?xml version="1.0" encoding="utf-8"?> |
2861 | +<openerp> |
2862 | + <data> |
2863 | + |
2864 | + <record id="account_general_ledger_cumulative_report_view_xls" model="ir.ui.view"> |
2865 | + <field name="name">account general ledger cumulative report XLS</field> |
2866 | + <field name="model">fl.account.general.ledger.cumulative.report</field> |
2867 | + <field name="type">form</field> |
2868 | + <field name="inherit_id" ref="account_financial_report_web.account_general_ledger_cumulative_report_form2" /> |
2869 | + <field name="arch" type="xml"> |
2870 | + <data> |
2871 | + |
2872 | + <field name="initial_balance" position="after"> |
2873 | + <newline/> |
2874 | + <separator string="XLS" colspan="4"/> |
2875 | + <field name="name" invisible="1"/> |
2876 | + <field name="export_file" filename="name" /> |
2877 | + <button icon="gtk-print" name="get_report_file_xls" string="Export XLS" type="object" colspan="2" default_focus="1"/> |
2878 | + |
2879 | + </field> |
2880 | + </data> |
2881 | + </field> |
2882 | + </record> |
2883 | + |
2884 | + </data> |
2885 | +</openerp> |
2886 | |
2887 | === added directory 'report_general_ledger_xls' |
2888 | === added file 'report_general_ledger_xls/__init__.py' |
2889 | --- report_general_ledger_xls/__init__.py 1970-01-01 00:00:00 +0000 |
2890 | +++ report_general_ledger_xls/__init__.py 2014-01-29 11:51:34 +0000 |
2891 | @@ -0,0 +1,29 @@ |
2892 | +############################################################################## |
2893 | +# |
2894 | +# Copyright (c) 2014 Factor Libre S.L. (http://www.factorlibre.com) All Rights Reserved. |
2895 | +# |
2896 | +# Developer Rafael Valle |
2897 | +# WARNING: This program as such is intended to be used by professional |
2898 | +# programmers who take the whole responsability of assessing all potential |
2899 | +# consequences resulting from its eventual inadequacies and bugs |
2900 | +# End users who are looking for a ready-to-use solution with commercial |
2901 | +# garantees and support are strongly adviced to contract a Free Software |
2902 | +# Service Company |
2903 | +# |
2904 | +# This program is Free Software; you can redistribute it and/or |
2905 | +# modify it under the terms of the GNU General Public License |
2906 | +# as published by the Free Software Foundation; either version 2 |
2907 | +# of the License, or (at your option) any later version. |
2908 | +# |
2909 | +# This program is distributed in the hope that it will be useful, |
2910 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2911 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2912 | +# GNU General Public License for more details. |
2913 | +# |
2914 | +# You should have received a copy of the GNU General Public License |
2915 | +# along with this program; if not, write to the Free Software |
2916 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
2917 | +# |
2918 | +############################################################################## |
2919 | + |
2920 | +import wizard |
2921 | |
2922 | === added file 'report_general_ledger_xls/__openerp__.py' |
2923 | --- report_general_ledger_xls/__openerp__.py 1970-01-01 00:00:00 +0000 |
2924 | +++ report_general_ledger_xls/__openerp__.py 2014-01-29 11:51:34 +0000 |
2925 | @@ -0,0 +1,39 @@ |
2926 | +# -*- coding: utf-8 -*- |
2927 | +############################################################################## |
2928 | +# |
2929 | +# OpenERP, Open Source Management Solution |
2930 | +# Copyright (C) 2014 Factor Libre S.L (<http://www.factorlibre.com>). |
2931 | +# Developer Rafael Valle |
2932 | +# |
2933 | +# This program is free software: you can redistribute it and/or modify |
2934 | +# it under the terms of the GNU Affero General Public License as |
2935 | +# published by the Free Software Foundation, either version 3 of the |
2936 | +# License, or (at your option) any later version. |
2937 | +# |
2938 | +# This program is distributed in the hope that it will be useful, |
2939 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2940 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2941 | +# GNU Affero General Public License for more details. |
2942 | +# |
2943 | +# You should have received a copy of the GNU Affero General Public License |
2944 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2945 | +# |
2946 | +############################################################################## |
2947 | + |
2948 | +{ |
2949 | + "name" : "report general ledger xls", |
2950 | + "description": """Allows get general ledger in xls""", |
2951 | + "version" : "1.0", |
2952 | + "author" : "Factor Libre S.L", |
2953 | + "category" : "Generic Modules", |
2954 | + "module": "", |
2955 | + "website": "http://www.factorlibre.com/", |
2956 | + "depends" : ["account"], |
2957 | + "init_xml" : [], |
2958 | + "update_xml" : [ |
2959 | + "wizard/account_report_ledger_xls_view.xml", |
2960 | + ], |
2961 | + "demo_xml" : [], |
2962 | + "active": False, |
2963 | + "installable": True |
2964 | +} |
2965 | |
2966 | === added directory 'report_general_ledger_xls/i18n' |
2967 | === added file 'report_general_ledger_xls/i18n/es.mo' |
2968 | Binary files report_general_ledger_xls/i18n/es.mo 1970-01-01 00:00:00 +0000 and report_general_ledger_xls/i18n/es.mo 2014-01-29 11:51:34 +0000 differ |
2969 | === added file 'report_general_ledger_xls/i18n/es.po' |
2970 | --- report_general_ledger_xls/i18n/es.po 1970-01-01 00:00:00 +0000 |
2971 | +++ report_general_ledger_xls/i18n/es.po 2014-01-29 11:51:34 +0000 |
2972 | @@ -0,0 +1,63 @@ |
2973 | +# Translation of OpenERP Server. |
2974 | +# This file contains the translation of the following modules: |
2975 | +# * fl_report_general_ledger_xls |
2976 | +# |
2977 | +msgid "" |
2978 | +msgstr "" |
2979 | +"Project-Id-Version: OpenERP Server 6.1-20130627-233424\n" |
2980 | +"Report-Msgid-Bugs-To: \n" |
2981 | +"POT-Creation-Date: 2014-01-17 10:06+0000\n" |
2982 | +"PO-Revision-Date: 2014-01-17 11:07+0100\n" |
2983 | +"Last-Translator: <>\n" |
2984 | +"Language-Team: \n" |
2985 | +"MIME-Version: 1.0\n" |
2986 | +"Content-Type: text/plain; charset=UTF-8\n" |
2987 | +"Content-Transfer-Encoding: 8bit\n" |
2988 | +"Plural-Forms: \n" |
2989 | +"X-Generator: Poedit 1.5.4\n" |
2990 | + |
2991 | +#. module: fl_report_general_ledger_xls |
2992 | +#: constraint:account.report.general.ledger:0 |
2993 | +msgid "" |
2994 | +"The fiscalyear, periods or chart of account chosen have to belong to the " |
2995 | +"same company." |
2996 | +msgstr "" |
2997 | +"El ejercicio fiscal, periodos y árbol de cuentas escogido deben pertenecer a " |
2998 | +"la misma compañía." |
2999 | + |
3000 | +#. module: fl_report_general_ledger_xls |
3001 | +#: field:account.report.general.ledger,export_file:0 |
3002 | +msgid "Export File" |
3003 | +msgstr "Fichero" |
3004 | + |
3005 | +#. module: fl_report_general_ledger_xls |
3006 | +#: code:addons/fl_report_general_ledger_xls/wizard/account_report_general_ledger.py:69 |
3007 | +#, python-format |
3008 | +msgid "All Posted Entries" |
3009 | +msgstr "All Posted Entries" |
3010 | + |
3011 | +#. module: fl_report_general_ledger_xls |
3012 | +#: field:account.report.general.ledger,name:0 |
3013 | +msgid "Filename" |
3014 | +msgstr "Nombre de fichero" |
3015 | + |
3016 | +#. module: fl_report_general_ledger_xls |
3017 | +#: model:ir.model,name:fl_report_general_ledger_xls.model_account_report_general_ledger |
3018 | +msgid "General Ledger Report" |
3019 | +msgstr "Informe del libro mayor" |
3020 | + |
3021 | +#. module: fl_report_general_ledger_xls |
3022 | +#: view:account.report.general.ledger:0 |
3023 | +msgid "XLS" |
3024 | +msgstr "XLS" |
3025 | + |
3026 | +#. module: fl_report_general_ledger_xls |
3027 | +#: code:addons/fl_report_general_ledger_xls/wizard/account_report_general_ledger.py:68 |
3028 | +#, python-format |
3029 | +msgid "All Entries" |
3030 | +msgstr "All Entries" |
3031 | + |
3032 | +#. module: fl_report_general_ledger_xls |
3033 | +#: view:account.report.general.ledger:0 |
3034 | +msgid "Export XLS" |
3035 | +msgstr "Generar XLS" |
3036 | |
3037 | === added directory 'report_general_ledger_xls/wizard' |
3038 | === added file 'report_general_ledger_xls/wizard/__init__.py' |
3039 | --- report_general_ledger_xls/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
3040 | +++ report_general_ledger_xls/wizard/__init__.py 2014-01-29 11:51:34 +0000 |
3041 | @@ -0,0 +1,27 @@ |
3042 | +# -*- coding: utf-8 -*- |
3043 | +############################################################################## |
3044 | +# |
3045 | +# OpenERP, Open Source Management Solution |
3046 | +# Copyright (C) 2014 Rafael Valle (Factor Libre S.L) (<http://factorlibre.com>). |
3047 | +# |
3048 | +# This program is free software: you can redistribute it and/or modify |
3049 | +# it under the terms of the GNU Affero General Public License as |
3050 | +# published by the Free Software Foundation, either version 3 of the |
3051 | +# License, or (at your option) any later version. |
3052 | +# |
3053 | +# This program is distributed in the hope that it will be useful, |
3054 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3055 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3056 | +# GNU Affero General Public License for more details. |
3057 | +# |
3058 | +# You should have received a copy of the GNU Affero General Public License |
3059 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
3060 | +# |
3061 | +############################################################################## |
3062 | + |
3063 | +import account_report_general_ledger |
3064 | + |
3065 | + |
3066 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
3067 | + |
3068 | + |
3069 | |
3070 | === added file 'report_general_ledger_xls/wizard/account_report_general_ledger.py' |
3071 | --- report_general_ledger_xls/wizard/account_report_general_ledger.py 1970-01-01 00:00:00 +0000 |
3072 | +++ report_general_ledger_xls/wizard/account_report_general_ledger.py 2014-01-29 11:51:34 +0000 |
3073 | @@ -0,0 +1,407 @@ |
3074 | +# -*- coding: utf-8 -*- |
3075 | +############################################################################## |
3076 | +# |
3077 | +# OpenERP, Open Source Management Solution |
3078 | +# Copyright (C) 2013 Factor Libre. |
3079 | +# Developer Rafael Valle |
3080 | +# |
3081 | +# This program is free software: you can redistribute it and/or modify |
3082 | +# it under the terms of the GNU Affero General Public License as |
3083 | +# published by the Free Software Foundation, either version 3 of the |
3084 | +# License, or (at your option) any later version. |
3085 | +# |
3086 | +# This program is distributed in the hope that it will be useful, |
3087 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3088 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3089 | +# GNU Affero General Public License for more details. |
3090 | +# |
3091 | +# You should have received a copy of the GNU Affero General Public License |
3092 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
3093 | +# |
3094 | +############################################################################## |
3095 | + |
3096 | +import time, dateutil, dateutil.tz |
3097 | +from datetime import date, datetime |
3098 | + |
3099 | +import cStringIO |
3100 | +import base64 |
3101 | +from xlwt import * |
3102 | +import pooler |
3103 | +from osv import osv, fields |
3104 | +from tools.translate import _ |
3105 | +import logging |
3106 | +_logger = logging.getLogger(__name__) |
3107 | + |
3108 | +class account_report_general_ledger(osv.osv_memory): |
3109 | + _inherit = "account.report.general.ledger" |
3110 | + |
3111 | + |
3112 | + |
3113 | + _columns = { |
3114 | + 'name': fields.char('Filename', size=64, readonly=True), |
3115 | + 'export_file': fields.binary('Export File', readonly=True), |
3116 | + } |
3117 | + |
3118 | + |
3119 | + |
3120 | + def _get_account(self, cr, uid, data): |
3121 | + if data.get('form', False) and data['form'].get('chart_account_id', False): |
3122 | + return pooler.get_pool(cr.dbname).get('account.account').browse(cr, uid, data['form']['chart_account_id']).name |
3123 | + return '' |
3124 | + |
3125 | + |
3126 | + def _get_fiscalyear(self, cr, uid, data): |
3127 | + if data.get('form', False) and data['form'].get('fiscalyear_id', False): |
3128 | + return pooler.get_pool(cr.dbname).get('account.fiscalyear').browse(cr, uid, data['form']['fiscalyear_id']).name |
3129 | + return '' |
3130 | + |
3131 | + def _get_journal(self, cr, uid, data): |
3132 | + codes = [] |
3133 | + if data.get('form', False) and data['form'].get('journal_ids', False): |
3134 | + cr.execute('select code from account_journal where id IN %s',(tuple(data['form']['journal_ids']),)) |
3135 | + codes = ','.join([x for x, in cr.fetchall()]) |
3136 | + return codes |
3137 | + |
3138 | + def _get_target_move(self, cr, uid, data): |
3139 | + if data.get('form', False) and data['form'].get('target_move', False): |
3140 | + if data['form']['target_move'] == 'all': |
3141 | + return _('All Entries') |
3142 | + return _('All Posted Entries') |
3143 | + return '' |
3144 | + |
3145 | + |
3146 | + |
3147 | + |
3148 | + def _sum_balance_account(self, cr, uid, account, query, target_move, init_balance): |
3149 | + if account.type == 'view': |
3150 | + return account.balance |
3151 | + move_state = ['draft','posted'] |
3152 | + if target_move == 'posted': |
3153 | + move_state = ['posted',''] |
3154 | + cr.execute('SELECT (sum(debit) - sum(credit)) as tot_balance \ |
3155 | + FROM account_move_line l \ |
3156 | + JOIN account_move am ON (am.id = l.move_id) \ |
3157 | + WHERE (l.account_id = %s) \ |
3158 | + AND (am.state IN %s) \ |
3159 | + AND '+ query +' ' |
3160 | + ,(account.id, tuple(move_state))) |
3161 | + sum_balance = cr.fetchone()[0] or 0.0 |
3162 | + if init_balance: |
3163 | + cr.execute('SELECT (sum(debit) - sum(credit)) as tot_balance \ |
3164 | + FROM account_move_line l \ |
3165 | + JOIN account_move am ON (am.id = l.move_id) \ |
3166 | + WHERE (l.account_id = %s) \ |
3167 | + AND (am.state IN %s) \ |
3168 | + AND '+ self.init_query +' ' |
3169 | + ,(account.id, tuple(move_state))) |
3170 | + # Add initial balance to the result |
3171 | + sum_balance += cr.fetchone()[0] or 0.0 |
3172 | + return sum_balance |
3173 | + |
3174 | + |
3175 | + def _sum_credit_account(self, cr, uid, account, target_move, init_balance, query, init_query): |
3176 | + if account.type == 'view': |
3177 | + return account.credit |
3178 | + move_state = ['draft','posted'] |
3179 | + if target_move == 'posted': |
3180 | + move_state = ['posted',''] |
3181 | + cr.execute('SELECT sum(credit) \ |
3182 | + FROM account_move_line l \ |
3183 | + JOIN account_move am ON (am.id = l.move_id) \ |
3184 | + WHERE (l.account_id = %s) \ |
3185 | + AND (am.state IN %s) \ |
3186 | + AND '+ query +' ' |
3187 | + ,(account.id, tuple(move_state))) |
3188 | + sum_credit = cr.fetchone()[0] or 0.0 |
3189 | + if init_balance: |
3190 | + cr.execute('SELECT sum(credit) \ |
3191 | + FROM account_move_line l \ |
3192 | + JOIN account_move am ON (am.id = l.move_id) \ |
3193 | + WHERE (l.account_id = %s) \ |
3194 | + AND (am.state IN %s) \ |
3195 | + AND '+ init_query +' ' |
3196 | + ,(account.id, tuple(move_state))) |
3197 | + # Add initial balance to the result |
3198 | + sum_credit += cr.fetchone()[0] or 0.0 |
3199 | + return sum_credit |
3200 | + |
3201 | + def _sum_debit_account(self, cr, uid, account, target_move, init_balance, query, init_query): |
3202 | + if account.type == 'view': |
3203 | + return account.debit |
3204 | + move_state = ['draft','posted'] |
3205 | + if target_move == 'posted': |
3206 | + move_state = ['posted',''] |
3207 | + cr.execute('SELECT sum(debit) \ |
3208 | + FROM account_move_line l \ |
3209 | + JOIN account_move am ON (am.id = l.move_id) \ |
3210 | + WHERE (l.account_id = %s) \ |
3211 | + AND (am.state IN %s) \ |
3212 | + AND '+ query +' ' |
3213 | + ,(account.id, tuple(move_state))) |
3214 | + sum_debit = cr.fetchone()[0] or 0.0 |
3215 | + if init_balance: |
3216 | + cr.execute('SELECT sum(debit) \ |
3217 | + FROM account_move_line l \ |
3218 | + JOIN account_move am ON (am.id = l.move_id) \ |
3219 | + WHERE (l.account_id = %s) \ |
3220 | + AND (am.state IN %s) \ |
3221 | + AND '+ init_query +' ' |
3222 | + ,(account.id, tuple(move_state))) |
3223 | + # Add initial balance to the result |
3224 | + sum_debit += cr.fetchone()[0] or 0.0 |
3225 | + return sum_debit |
3226 | + |
3227 | + def get_children_accounts(self, cr, uid, account, data, context): |
3228 | + res = [] |
3229 | + |
3230 | + ctx2 = data['form'].get('used_context',{}).copy() |
3231 | + query = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=data['form'].get('used_context',{})) |
3232 | + sold_accounts = {} |
3233 | + display_account = data['form']['display_account'] |
3234 | + target_move = data['form'].get('target_move', 'all') |
3235 | + init_balance = data['form'].get('initial_balance', True) |
3236 | + if init_balance: |
3237 | + ctx2.update({'initial_bal': True}) |
3238 | + init_query = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=ctx2) |
3239 | + |
3240 | + account=self.pool.get('account.account').browse(cr,uid,account) |
3241 | + currency_obj = self.pool.get('res.currency') |
3242 | + ids_acc = self.pool.get('account.account')._get_children_and_consol(cr, uid, account.id) |
3243 | + currency = account.currency_id and account.currency_id or account.company_id.currency_id |
3244 | + for child_account in self.pool.get('account.account').browse(cr, uid, ids_acc, context=context): |
3245 | + sql = """ |
3246 | + SELECT count(id) |
3247 | + FROM account_move_line AS l |
3248 | + WHERE %s AND l.account_id = %%s |
3249 | + """ % (query) |
3250 | + cr.execute(sql, (child_account.id,)) |
3251 | + num_entry = cr.fetchone()[0] or 0 |
3252 | + sold_account = self._sum_balance_account(cr, uid, child_account, query, target_move, init_balance) |
3253 | + sold_accounts[child_account.id] = sold_account |
3254 | + if display_account == 'movement': |
3255 | + if child_account.type != 'view' and num_entry <> 0: |
3256 | + res.append(child_account) |
3257 | + elif display_account == 'not_zero': |
3258 | + if child_account.type != 'view' and num_entry <> 0: |
3259 | + if not currency_obj.is_zero(cr, uid, currency, sold_account): |
3260 | + res.append(child_account) |
3261 | + else: |
3262 | + res.append(child_account) |
3263 | + if not res: |
3264 | + return [account] |
3265 | + return res |
3266 | + |
3267 | + |
3268 | + |
3269 | + def _get_period(self, cr, uid, move): |
3270 | + if move: |
3271 | + acc_move_ids=self.pool.get('account.move').search(cr, uid, [('name','=',move)]) |
3272 | + if acc_move_ids: |
3273 | + acc_move_obj=self.pool.get('account.move').browse(cr, uid, acc_move_ids[0]) |
3274 | + if acc_move_obj.period_id: |
3275 | + return acc_move_obj.period_id.name |
3276 | + return '' |
3277 | + |
3278 | + |
3279 | + def lines(self, cr, uid, account, sortby, tot_currency, target_move, init_balance, query, init_query): |
3280 | + """ Return all the account_move_line of account with their account code counterparts """ |
3281 | + move_state = ['draft','posted'] |
3282 | + if target_move == 'posted': |
3283 | + move_state = ['posted', ''] |
3284 | + # First compute all counterpart strings for every move_id where this account appear. |
3285 | + # Currently, the counterpart info is used only in landscape mode |
3286 | + sql = """ |
3287 | + SELECT m1.move_id, |
3288 | + array_to_string(ARRAY(SELECT DISTINCT a.code |
3289 | + FROM account_move_line m2 |
3290 | + LEFT JOIN account_account a ON (m2.account_id=a.id) |
3291 | + WHERE m2.move_id = m1.move_id |
3292 | + AND m2.account_id<>%%s), ', ') AS counterpart |
3293 | + FROM (SELECT move_id |
3294 | + FROM account_move_line l |
3295 | + LEFT JOIN account_move am ON (am.id = l.move_id) |
3296 | + WHERE am.state IN %s and %s AND l.account_id = %%s GROUP BY move_id) m1 |
3297 | + """% (tuple(move_state), query) |
3298 | + cr.execute(sql, (account.id, account.id)) |
3299 | + counterpart_res = cr.dictfetchall() |
3300 | + counterpart_accounts = {} |
3301 | + for i in counterpart_res: |
3302 | + counterpart_accounts[i['move_id']] = i['counterpart'] |
3303 | + del counterpart_res |
3304 | + |
3305 | + # Then select all account_move_line of this account |
3306 | + if sortby == 'sort_journal_partner': |
3307 | + sql_sort='j.code, p.name, l.move_id' |
3308 | + else: |
3309 | + sql_sort='l.date, l.move_id' |
3310 | + sql = """ |
3311 | + SELECT l.id AS lid, l.date AS ldate, j.code AS lcode, l.currency_id,l.amount_currency,l.ref AS lref, l.name AS lname, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id AS lperiod_id, l.partner_id AS lpartner_id, |
3312 | + m.name AS move_name, m.id AS mmove_id,per.code as period_code, |
3313 | + c.symbol AS currency_code, |
3314 | + i.id AS invoice_id, i.type AS invoice_type, i.number AS invoice_number, |
3315 | + p.name AS partner_name |
3316 | + FROM account_move_line l |
3317 | + JOIN account_move m on (l.move_id=m.id) |
3318 | + LEFT JOIN res_currency c on (l.currency_id=c.id) |
3319 | + LEFT JOIN res_partner p on (l.partner_id=p.id) |
3320 | + LEFT JOIN account_invoice i on (m.id =i.move_id) |
3321 | + LEFT JOIN account_period per on (per.id=l.period_id) |
3322 | + JOIN account_journal j on (l.journal_id=j.id) |
3323 | + WHERE %s AND m.state IN %s AND l.account_id = %%s ORDER by %s |
3324 | + """ %(query, tuple(move_state), sql_sort) |
3325 | + cr.execute(sql, (account.id,)) |
3326 | + res_lines = cr.dictfetchall() |
3327 | + res_init = [] |
3328 | + if res_lines and init_balance: |
3329 | + #FIXME: replace the label of lname with a string translatable |
3330 | + sql = """ |
3331 | + SELECT 0 AS lid, '' AS ldate, '' AS lcode, COALESCE(SUM(l.amount_currency),0.0) AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, '' AS lperiod_id, '' AS lpartner_id, |
3332 | + '' AS move_name, '' AS mmove_id, '' AS period_code, |
3333 | + '' AS currency_code, |
3334 | + NULL AS currency_id, |
3335 | + '' AS invoice_id, '' AS invoice_type, '' AS invoice_number, |
3336 | + '' AS partner_name |
3337 | + FROM account_move_line l |
3338 | + LEFT JOIN account_move m on (l.move_id=m.id) |
3339 | + LEFT JOIN res_currency c on (l.currency_id=c.id) |
3340 | + LEFT JOIN res_partner p on (l.partner_id=p.id) |
3341 | + LEFT JOIN account_invoice i on (m.id =i.move_id) |
3342 | + JOIN account_journal j on (l.journal_id=j.id) |
3343 | + WHERE %s AND m.state IN %s AND l.account_id = %%s |
3344 | + """ %(init_query, tuple(move_state)) |
3345 | + cr.execute(sql, (account.id,)) |
3346 | + res_init = cr.dictfetchall() |
3347 | + res = res_init + res_lines |
3348 | + account_sum = 0.0 |
3349 | + for l in res: |
3350 | + l['move'] = l['move_name'] != '/' and l['move_name'] or ('*'+str(l['mmove_id'])) |
3351 | + l['partner'] = l['partner_name'] or '' |
3352 | + account_sum += l['debit'] - l['credit'] |
3353 | + l['progress'] = account_sum |
3354 | + l['line_corresp'] = l['mmove_id'] == '' and ' ' or counterpart_accounts[l['mmove_id']].replace(', ',',') |
3355 | + # Modification of amount Currency |
3356 | + if l['credit'] > 0: |
3357 | + if l['amount_currency'] != None: |
3358 | + l['amount_currency'] = abs(l['amount_currency']) * -1 |
3359 | + if l['amount_currency'] != None: |
3360 | + tot_currency = tot_currency + l['amount_currency'] |
3361 | + return res |
3362 | + |
3363 | + def get_report_file_xls(self, cr, uid, ids, context=None): |
3364 | + |
3365 | + if context is None: |
3366 | + context = {} |
3367 | + |
3368 | + data=self.check_report(cr, uid, ids, context) |
3369 | + |
3370 | + #vals context |
3371 | + ctx2 = data['datas']['form'].get('used_context',{}).copy() |
3372 | + tot_currency = 0.0 |
3373 | + sortby = data['datas']['form'].get('sortby', 'sort_date') |
3374 | + query = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=data['datas']['form'].get('used_context',{})) |
3375 | + sold_accounts = {} |
3376 | + display_account = data['datas']['form']['display_account'] |
3377 | + target_move = data['datas']['form'].get('target_move', 'all') |
3378 | + init_balance = data['datas']['form'].get('initial_balance', True) |
3379 | + if init_balance: |
3380 | + ctx2.update({'initial_bal': True}) |
3381 | + init_query = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=ctx2) |
3382 | + |
3383 | + user = self.pool.get('res.users').browse(cr, uid, uid, context = context) |
3384 | + |
3385 | + user_tz = dateutil.tz.gettz(user.context_tz) |
3386 | + utc_tz = dateutil.tz.tzutc() |
3387 | + |
3388 | + |
3389 | + excel_temp = cStringIO.StringIO() |
3390 | + w = Workbook(encoding='utf-8', style_compression=2) |
3391 | + ws = w.add_sheet('Hoja 1') |
3392 | + |
3393 | + #styles |
3394 | + style_headers1 = XFStyle() |
3395 | + # font |
3396 | + font = Font() |
3397 | + font.bold = True |
3398 | + style_headers1.font = font |
3399 | + # borders |
3400 | + borders = Borders() |
3401 | + borders.bottom = Borders.DASHED |
3402 | + style_headers1.borders = borders |
3403 | + |
3404 | + style_bold = XFStyle() |
3405 | + # font |
3406 | + font = Font() |
3407 | + font.bold = True |
3408 | + style_bold.font = font |
3409 | + |
3410 | + |
3411 | + # Header definition |
3412 | + ws.write_merge(0, 0, 0, 11,'LIBRO MAYOR',style=style_headers1) |
3413 | + |
3414 | + |
3415 | + #Main Headers |
3416 | + ws.write(1,0,'Plan Contable', style=style_headers1) |
3417 | + ws.write(2,0,'Ejercicio Fiscal', style=style_headers1) |
3418 | + ws.write(3,0,'Diarios', style=style_headers1) |
3419 | + ws.write(4,0,'Movimientos destino', style=style_headers1) |
3420 | + |
3421 | + ws.write(1,1,self._get_account(cr,uid,data['datas'])) |
3422 | + ws.write(2,1,self._get_fiscalyear(cr,uid,data['datas'])) |
3423 | + ws.write(3,1,self._get_journal(cr,uid,data['datas'])) |
3424 | + ws.write(4,1,self._get_target_move(cr,uid,data['datas'])) |
3425 | + |
3426 | + |
3427 | + #Table headers |
3428 | + |
3429 | + ws.write(6,0,'Fecha', style=style_headers1) |
3430 | + ws.write(6,1,'Periodo', style=style_headers1) |
3431 | + ws.write(6,2,'Libro', style=style_headers1) |
3432 | + ws.write(6,3,'Empresa', style=style_headers1) |
3433 | + ws.write(6,4,'Ref', style=style_headers1) |
3434 | + ws.write(6,5,'Asiento', style=style_headers1) |
3435 | + ws.write(6,6,'Etiqueta Asiento', style=style_headers1) |
3436 | + ws.write(6,7,'Contrapartida', style=style_headers1) |
3437 | + ws.write(6,8,'Debe', style=style_headers1) |
3438 | + ws.write(6,9,'Haber', style=style_headers1) |
3439 | + ws.write(6,10,'Saldo Pendiente', style=style_headers1) |
3440 | + ws.write(6,11,'Divisa', style=style_headers1) |
3441 | + |
3442 | + row=7 |
3443 | + #Children accounts |
3444 | + for a in self.get_children_accounts(cr, uid, data['datas']['form']['chart_account_id'],data['datas'], context): |
3445 | + ws.write(row,0,a.code+' '+a.name, style=style_bold) |
3446 | + ws.write(row,8,self._sum_debit_account(cr, uid, a, target_move, init_balance, query, init_query), style=style_bold) |
3447 | + ws.write(row,9,self._sum_credit_account(cr, uid, a, target_move, init_balance, query, init_query), style=style_bold) |
3448 | + #ws.write(row,10,self._sum_balance_account(cr, uid, a, query, target_move, init_balance)) |
3449 | + row=row+1 |
3450 | + |
3451 | + #lines children |
3452 | + for a_line in self.lines(cr, uid, a, sortby, tot_currency, target_move, init_balance, query, init_query): |
3453 | + |
3454 | + #format date |
3455 | + ldated=datetime.strptime(a_line['ldate'], '%Y-%m-%d') |
3456 | + |
3457 | + ws.write(row,0,ldated.strftime('%d/%m/%Y')) |
3458 | + ws.write(row,1,self._get_period(cr, uid, a_line['move'])) |
3459 | + ws.write(row,2,a_line['lcode']) |
3460 | + ws.write(row,3,a_line['partner_name']) |
3461 | + ws.write(row,4,a_line['lref']) |
3462 | + ws.write(row,5,a_line['move']) |
3463 | + ws.write(row,6,a_line['lname']) |
3464 | + ws.write(row,7,a_line['line_corresp']) |
3465 | + ws.write(row,8,a_line['debit']) |
3466 | + ws.write(row,9,a_line['credit']) |
3467 | + ws.write(row,10,a_line['progress']) |
3468 | + ws.write(row,11,a_line['currency_code'] or '') |
3469 | + row=row+1 |
3470 | + |
3471 | + w.save(excel_temp) |
3472 | + out=base64.encodestring(excel_temp.getvalue()) |
3473 | + excel_temp.close() |
3474 | + file_time = datetime.now(user_tz).strftime('%Y-%m-%d_%H%M') |
3475 | + |
3476 | + |
3477 | + return self.write(cr, uid, ids, {'state': 'export', 'export_file': out, 'name': 'Libro_Mayor_%s.xls' % (file_time)}) |
3478 | + |
3479 | +account_report_general_ledger() |
3480 | + |
3481 | |
3482 | === added file 'report_general_ledger_xls/wizard/account_report_ledger_xls_view.xml' |
3483 | --- report_general_ledger_xls/wizard/account_report_ledger_xls_view.xml 1970-01-01 00:00:00 +0000 |
3484 | +++ report_general_ledger_xls/wizard/account_report_ledger_xls_view.xml 2014-01-29 11:51:34 +0000 |
3485 | @@ -0,0 +1,26 @@ |
3486 | +<?xml version="1.0" encoding="utf-8"?> |
3487 | +<openerp> |
3488 | + <data> |
3489 | + |
3490 | + <record id="account_report_general_ledger_view_xls" model="ir.ui.view"> |
3491 | + <field name="name">Account report general ledger XLS</field> |
3492 | + <field name="model">account.report.general.ledger</field> |
3493 | + <field name="type">form</field> |
3494 | + <field name="inherit_id" ref="account.account_common_report_view" /> |
3495 | + <field name="arch" type="xml"> |
3496 | + <data> |
3497 | + |
3498 | + <xpath expr="/form/notebook/page[@name='journal_ids']" position="after"> |
3499 | + <page string="XLS"> |
3500 | + <field name="name" invisible="1"/> |
3501 | + <field name="export_file" filename="name" /> |
3502 | + <newline/> |
3503 | + <button icon="gtk-print" name="get_report_file_xls" string="Export XLS" type="object" colspan="2" default_focus="1"/> |
3504 | + </page> |
3505 | + </xpath> |
3506 | + </data> |
3507 | + </field> |
3508 | + </record> |
3509 | + |
3510 | + </data> |
3511 | +</openerp> |
Es una propuesta nuestra de Factor Libre como comentamos en la lista.