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