Merge lp:~rafael-valle-z/openerp-spain/openerp-spain-xls-reports into lp:~openerp-spain-team/openerp-spain/6.1

Proposed by Rafael Valle
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
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

Description of the change

Añadidos 3 módulos:
- account_financial_report_web: Corrige algunos problemas con el cliente web
- report_general_ledger_xls: Permite generar el Libro Mayor en Excel
- report_cumulative_general_ledger_xls: Permite generar el Libro Mayor Acumulado en Excel

Probado en la versión 6.1

To post a comment you must log in.
Revision history for this message
Alberto Garcia (Factor Libre) (agarcia-flibre) wrote :

Es una propuesta nuestra de Factor Libre como comentamos en la lista.

review: Approve
Revision history for this message
Ignacio Ibeas (www.acysos.com) (ignacio-acysos) :
review: Approve
Revision history for this message
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

Revision history for this message
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.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Tened en cuenta que para la v7 en el repositorio account-financial-report hay un módulo para exportar los informes financieros en XLS, para por si os sirve de inspiración o complementarlo si falta algo.

Un saludo.

Revision history for this message
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'account_financial_report_web'
=== added file 'account_financial_report_web/__init__.py'
--- account_financial_report_web/__init__.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/__init__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,25 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import wizard
23import report
24
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
026
=== added file 'account_financial_report_web/__openerp__.py'
--- account_financial_report_web/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/__openerp__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,34 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2013 Factor Libre.
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{
23 "name": "Account Financial Report Web",
24 "version": "0.1",
25 "author": "Factor Libre",
26 "category": "Others",
27 "website": "http://www.factorlibre.com",
28 "description": "Update Account Financial Report (Factor Libre Project)",
29 "depends": ["base", "account_financial_report"],
30 "init_xml": [],
31 "update_xml": ["account_report_report.xml","account_report_wizard.xml",],
32 "active": False,
33 "installable": True,
34}
035
=== added file 'account_financial_report_web/account_report_report.xml'
--- account_financial_report_web/account_report_report.xml 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/account_report_report.xml 2014-01-29 11:51:34 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data >
4
5 # Report full account balance
6 <report
7 id="account_balance_full3"
8 string="**Full account balance"
9 model="account.account"
10 name="account.balance.full3"
11 rml="fl_account_financial_report/report/account_balance_full.rml"
12 header="False"
13 auto="False"
14 menu="False"/>
15
16 </data>
17</openerp>
018
=== added file 'account_financial_report_web/account_report_wizard.xml'
--- account_financial_report_web/account_report_wizard.xml 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/account_report_wizard.xml 2014-01-29 11:51:34 +0000
@@ -0,0 +1,115 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data >
4 <record id="account_balance_full_report_form3" model="ir.ui.view">
5 <field name="name">account.balance.full.report.form3</field>
6 <field name="model">fl.account.balance.full.report</field>
7 <field name="type">form</field>
8 <field name="arch" type="xml">
9 <form string="Full Account Balance2">
10 <field name="company_id" on_change="onchange_company_id(company_id)"/>
11 <newline/>
12 <group colspan="4">
13 <separator string="Accounts to include" colspan="4"/>
14 <field name="account_list" nolabel="1" colspan="4" domain="[('company_id','=',company_id)]"/>
15 <field name="display_account" required="True"/>
16 <field name="display_account_level" required="True" />
17 </group>
18 <group colspan="4">
19 <separator string="Period" colspan="4"/>
20 <field name="fiscalyear"/>
21 <newline/>
22 <field name="state" required="True"/>
23 <newline/>
24 <group attrs="{'invisible':[('state','=','none')]}" colspan="4">
25 <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
26 <separator string="Date Filter" colspan="4"/>
27 <field name="date_from"/>
28 <field name="date_to"/>
29 </group>
30 <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
31 <separator string="Filter on Periods" colspan="4"/>
32 <field name="periods" colspan="4" nolabel="1" domain="[('fiscalyear_id','=',fiscalyear)]"/>
33 </group>
34 </group>
35 </group>
36 <button special="cancel" string="Cancel" icon="gtk-cancel"/>
37 <button name="print_report" string="Get Balance" type="object" icon="gtk-ok"/>
38 </form>
39 </field>
40 </record>
41
42 <record id="action_balance_full_xml_report3" model="ir.actions.act_window">
43 <field name="name">**Full account balance3</field>
44 <field name="res_model">fl.account.balance.full.report</field>
45 <field name="view_type">form</field>
46 <field name="view_mode">form</field>
47 <field name="view_id" ref="account_balance_full_report_form3"/>
48 <field name="target">new</field>
49 </record>
50 <menuitem id="account_financial_report.menu_account_balance_full_report" action="action_balance_full_xml_report3"
51 parent="account.menu_finance_generic_reporting" icon="STOCK_PRINT"
52 name="**Full account balance" sequence="100"/>
53
54 <record id="account_general_ledger_cumulative_report_form2" model="ir.ui.view">
55 <field name="name">account.general.ledger.cumulative.report.form2</field>
56 <field name="model">fl.account.general.ledger.cumulative.report</field>
57 <field name="type">form</field>
58 <field name="arch" type="xml">
59 <form string="General ledger">
60 <field name="states" invisible="1"/>
61 <newline/>
62 <group string="Select parent account" attrs="{'invisible':[('states','!=','account_selection')]}" width="700">
63 <field name="account_list" colspan="4" nolabel="1" attrs="{'required':[('states','=','account_selection')]}"/>
64 <newline/>
65 <button special="cancel" colspan="2" string="Cancel" icon="gtk-cancel"/>
66 <button name="step1" colspan="2" string="Next" type="object" icon="gtk-go-forward"/>
67 </group>
68 <newline/>
69 <group string="Select Date-Period" attrs="{'invisible':[('states','!=','checktype')]}" width="700" >
70 <field name="company_id" colspan="4" attrs="{'required':[('states','=','checktype')]}"/>
71 <newline/>
72 <field name="fiscalyear"/>
73 <label colspan="2" string="(Keep empty for all open fiscal years)" align="0.0"/>
74 <newline/>
75
76 <field name="display_account" attrs="{'required':[('states','=','checktype')]}"/>
77 <field name="sortbydate" attrs="{'required':[('states','=','checktype')]}"/>
78 <field name="landscape"/>
79 <field name="amount_currency"/>
80 <field name="initial_balance"/>
81 <newline/>
82 <separator string="Filters" colspan="4"/>
83 <field name="state" required="True"/>
84 <newline/>
85 <group attrs="{'invisible':[('state','=','none')]}" colspan="4">
86 <group attrs="{'invisible':[('state','=','byperiod')]}" colspan="4">
87 <separator string="Date Filter" colspan="4"/>
88 <field name="date_from"/>
89 <field name="date_to"/>
90 </group>
91 <group attrs="{'invisible':[('state','=','bydate')]}" colspan="4">
92 <separator string="Filter on Periods" colspan="4"/>
93 <field name="periods" colspan="4" nolabel="1"/>
94 </group>
95 </group>
96 <button special="cancel" colspan="2" string="Cancel" icon="gtk-cancel"/>
97 <button name="prints" colspan="2" string="Print Report" type="object" icon="gtk-print"/>
98 </group>
99 </form>
100 </field>
101 </record>
102
103 <record id="action_general_ledger_cumulative_xml_report2" model="ir.actions.act_window">
104 <field name="name">**Cumulative general ledger</field>
105 <field name="res_model">fl.account.general.ledger.cumulative.report</field>
106 <field name="view_type">form</field>
107 <field name="view_mode">form</field>
108 <field name="view_id" ref="account_general_ledger_cumulative_report_form2"/>
109 <field name="target">new</field>
110 </record>
111 <menuitem id="account_financial_report.menu_account_general_ledger_cumulative_report" action="action_general_ledger_cumulative_xml_report2"
112 parent="account.menu_finance_generic_reporting" icon="STOCK_PRINT"
113 name="**Cumulative general ledger" sequence="100"/>
114 </data>
115</openerp>
0116
=== added directory 'account_financial_report_web/i18n'
=== added file 'account_financial_report_web/i18n/es.po'
--- account_financial_report_web/i18n/es.po 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/i18n/es.po 2014-01-29 11:51:34 +0000
@@ -0,0 +1,367 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * fl_account_financial_report
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-06-18 10:38+0000\n"
10"PO-Revision-Date: 2013-06-18 10:38+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: fl_account_financial_report
19#: selection:fl.account.balance.full.report,state:0
20#: selection:fl.account.general.ledger.cumulative.report,state:0
21msgid "By Period"
22msgstr "Por periodo"
23
24#. module: fl_account_financial_report
25#: view:fl.account.balance.full.report:0
26msgid "Full Account Balance2"
27msgstr "Balance de sumas y saldos"
28
29#. module: fl_account_financial_report
30#: view:fl.account.general.ledger.cumulative.report:0
31msgid "Select parent account"
32msgstr "Seleccione cuenta"
33
34#. module: fl_account_financial_report
35#: field:fl.account.general.ledger.cumulative.report,sortbydate:0
36msgid "Sort by"
37msgstr "Ordenar por"
38
39#. module: fl_account_financial_report
40#: model:ir.model,name:fl_account_financial_report.model_fl_account_balance_full_report
41msgid "fl.account.balance.full.report"
42msgstr "fl.account.balance.full.report"
43
44#. module: fl_account_financial_report
45#: code:addons/fl_account_financial_report/report/general_ledger.py:344
46#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:348
47#, python-format
48msgid "Initial balance"
49msgstr "Balance inicial"
50
51#. module: fl_account_financial_report
52#: field:fl.account.general.ledger.cumulative.report,initial_balance:0
53msgid "Show initial balances"
54msgstr "Mostrar balance inicial"
55
56#. module: fl_account_financial_report
57#: view:fl.account.balance.full.report:0
58#: view:fl.account.general.ledger.cumulative.report:0
59msgid "Date Filter"
60msgstr "Filtro por fecha"
61
62#. module: fl_account_financial_report
63#: field:fl.account.general.ledger.cumulative.report,states:0
64msgid "State"
65msgstr "Estado"
66
67#. module: fl_account_financial_report
68#: field:fl.account.balance.full.report,display_account:0
69msgid "Display accounts "
70msgstr "Mostrar cuentas "
71
72#. module: fl_account_financial_report
73#: view:fl.account.general.ledger.cumulative.report:0
74msgid "Print Report"
75msgstr "Imprimir informe"
76
77#. module: fl_account_financial_report
78#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:227
79#, python-format
80msgid "Date to must be set between %s and %s"
81msgstr "La fecha debe ser entre %s y %s"
82
83#. module: fl_account_financial_report
84#: code:addons/fl_account_financial_report/report/general_ledger.py:283
85#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:287
86#, python-format
87msgid "SI: "
88msgstr "SI: "
89
90#. module: fl_account_financial_report
91#: field:fl.account.balance.full.report,date_from:0
92#: field:fl.account.general.ledger.cumulative.report,date_from:0
93msgid "Start date"
94msgstr "Fecha de inicio"
95
96#. module: fl_account_financial_report
97#: view:fl.account.balance.full.report:0
98#: view:fl.account.general.ledger.cumulative.report:0
99msgid "Filter on Periods"
100msgstr "Filtro por periodos"
101
102#. module: fl_account_financial_report
103#: selection:fl.account.general.ledger.cumulative.report,sortbydate:0
104msgid "Movement"
105msgstr "movimiento"
106
107#. module: fl_account_financial_report
108#: model:ir.model,name:fl_account_financial_report.model_fl_account_balance_full_report2
109msgid "fl.account.balance.full.report2"
110msgstr "fl.account.balance.full.report2"
111
112#. module: fl_account_financial_report
113#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:102
114#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:165
115#, python-format
116msgid "Error !"
117msgstr "Error !"
118
119#. module: fl_account_financial_report
120#: field:fl.account.balance.full.report,periods:0
121#: field:fl.account.general.ledger.cumulative.report,periods:0
122msgid "Periods"
123msgstr "Periodos"
124
125#. module: fl_account_financial_report
126#: field:fl.account.balance.full.report,company_id:0
127#: field:fl.account.general.ledger.cumulative.report,company_id:0
128msgid "Company"
129msgstr "Compañia"
130
131#. module: fl_account_financial_report
132#: view:fl.account.general.ledger.cumulative.report:0
133msgid "(Keep empty for all open fiscal years)"
134msgstr "(Mantener vacio para mostrar todos los ejercicios fiscales abiertos)"
135
136#. module: fl_account_financial_report
137#: selection:fl.account.balance.full.report,state:0
138#: selection:fl.account.general.ledger.cumulative.report,state:0
139msgid "No Filter"
140msgstr "Sin filtro"
141
142#. module: fl_account_financial_report
143#: selection:fl.account.general.ledger.cumulative.report,display_account:0
144msgid "With balance is not equal to 0"
145msgstr "Con balance diferente a 0"
146
147#. module: fl_account_financial_report
148#: model:ir.model,name:fl_account_financial_report.model_account_balance_full_report
149msgid "account.balance.full.report"
150msgstr "account.balance.full.report"
151
152#. module: fl_account_financial_report
153#: selection:fl.account.general.ledger.cumulative.report,sortbydate:0
154msgid "Date"
155msgstr "Fecha"
156
157#. module: fl_account_financial_report
158#: field:fl.account.general.ledger.cumulative.report,amount_currency:0
159msgid "With Currency"
160msgstr "Mostrar divisa"
161
162#. module: fl_account_financial_report
163#: view:fl.account.balance.full.report:0
164msgid "Accounts to include"
165msgstr "Cuentas a incluir"
166
167#. module: fl_account_financial_report
168#: view:fl.account.general.ledger.cumulative.report:0
169msgid "General ledger"
170msgstr "Libro mayor"
171
172#. module: fl_account_financial_report
173#: help:fl.account.balance.full.report,display_account_level:0
174msgid "Display accounts up to this level (0 to show all)"
175msgstr "Mostrar cuentas hasta este nivel de profundidad (0 para mostrar todas)"
176
177#. module: fl_account_financial_report
178#: selection:fl.account.balance.full.report,display_account:0
179#: selection:fl.account.general.ledger.cumulative.report,display_account:0
180msgid "With movements"
181msgstr "Con movimientos"
182
183#. module: fl_account_financial_report
184#: field:fl.account.general.ledger.cumulative.report,account_list:0
185msgid "Account"
186msgstr "Cuenta"
187
188#. module: fl_account_financial_report
189#: model:ir.actions.report.xml,name:fl_account_financial_report.account_balance_full3
190msgid "**Full account balance"
191msgstr "**Balance de sumas y saldos"
192
193#. module: fl_account_financial_report
194#: view:fl.account.general.ledger.cumulative.report:0
195msgid "Filters"
196msgstr "Filtros"
197
198#. module: fl_account_financial_report
199#: selection:fl.account.balance.full.report,state:0
200#: selection:fl.account.general.ledger.cumulative.report,state:0
201msgid "By Date and Period"
202msgstr "Por fecha y periodo"
203
204#. module: fl_account_financial_report
205#: field:fl.account.balance.full.report,account_list:0
206msgid "Root accounts"
207msgstr "Cuentas raiz"
208
209#. module: fl_account_financial_report
210#: code:addons/fl_account_financial_report/report/general_ledger.py:282
211#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:286
212#, python-format
213msgid "CI: "
214msgstr "CI: "
215
216#. module: fl_account_financial_report
217#: view:fl.account.general.ledger.cumulative.report:0
218msgid "Select Date-Period"
219msgstr "Seleccionar fecha y periodo"
220
221#. module: fl_account_financial_report
222#: help:fl.account.general.ledger.cumulative.report,fiscalyear:0
223msgid "Keep empty for all open fiscal year"
224msgstr "Mantener vacio para mostrar todos los ejercicios fiscales abiertos"
225
226#. module: fl_account_financial_report
227#: help:fl.account.balance.full.report,periods:0
228#: help:fl.account.general.ledger.cumulative.report,periods:0
229msgid "All periods in the fiscal year if empty"
230msgstr "Todos los periodos del ejercicio fiscal si no tiene contenido"
231
232#. module: fl_account_financial_report
233#: model:ir.actions.act_window,name:fl_account_financial_report.action_balance_full_xml_report3
234msgid "**Full account balance3"
235msgstr "**Balance sumas y saldos"
236
237#. module: fl_account_financial_report
238#: view:fl.account.balance.full.report:0
239msgid "Get Balance"
240msgstr "Obtener Balance"
241
242#. module: fl_account_financial_report
243#: code:addons/fl_account_financial_report/report/general_ledger.py:285
244#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:289
245#, python-format
246msgid "SR: "
247msgstr "SR: "
248
249#. module: fl_account_financial_report
250#: selection:fl.account.balance.full.report,state:0
251#: selection:fl.account.general.ledger.cumulative.report,state:0
252msgid "By Date"
253msgstr "By Date"
254
255#. module: fl_account_financial_report
256#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:165
257#, python-format
258msgid "La interseccion entre el periodo y fecha es vacio"
259msgstr "La interseccion entre el periodo y fecha es vacio"
260
261#. module: fl_account_financial_report
262#: selection:fl.account.balance.full.report,display_account:0
263msgid "With balance"
264msgstr "Con balance"
265
266#. module: fl_account_financial_report
267#: selection:fl.account.general.ledger.cumulative.report,states:0
268msgid "Check Type"
269msgstr "Check Type"
270
271#. module: fl_account_financial_report
272#: view:fl.account.general.ledger.cumulative.report:0
273msgid "Next"
274msgstr "Next"
275
276#. module: fl_account_financial_report
277#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:112
278#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:116
279#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:227
280#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:229
281#, python-format
282msgid "UserError"
283msgstr "UserError"
284
285#. module: fl_account_financial_report
286#: field:fl.account.balance.full.report,date_to:0
287#: field:fl.account.general.ledger.cumulative.report,date_to:0
288msgid "End date"
289msgstr "Fecha de fin"
290
291#. module: fl_account_financial_report
292#: selection:fl.account.balance.full.report,display_account:0
293#: selection:fl.account.general.ledger.cumulative.report,display_account:0
294msgid "All"
295msgstr "Todo"
296
297#. module: fl_account_financial_report
298#: code:addons/fl_account_financial_report/wizard/wizard_account_balance_report.py:229
299#, python-format
300msgid "Date not in a defined fiscal year"
301msgstr "La fecha no se encuentra en un ejercicio fiscal definido"
302
303#. module: fl_account_financial_report
304#: model:ir.actions.act_window,name:fl_account_financial_report.action_general_ledger_cumulative_xml_report2
305msgid "**Cumulative general ledger"
306msgstr "**Libro mayor acumulado"
307
308#. module: fl_account_financial_report
309#: field:fl.account.balance.full.report,state:0
310#: field:fl.account.general.ledger.cumulative.report,state:0
311msgid "Date/Period Filter"
312msgstr "Filtro fecha/periodo"
313
314#. module: fl_account_financial_report
315#: view:fl.account.balance.full.report:0
316msgid "Period"
317msgstr "Periodo"
318
319#. module: fl_account_financial_report
320#: model:ir.model,name:fl_account_financial_report.model_fl_account_general_ledger_cumulative_report
321msgid "fl.account.general.ledger.cumulative.report"
322msgstr "fl.account.general.ledger.cumulative.report"
323
324#. module: fl_account_financial_report
325#: code:addons/fl_account_financial_report/report/general_ledger.py:284
326#: code:addons/fl_account_financial_report/report/general_ledger_landscape.py:288
327#, python-format
328msgid "OR: "
329msgstr "OR: "
330
331#. module: fl_account_financial_report
332#: field:fl.account.balance.full.report,fiscalyear:0
333#: field:fl.account.general.ledger.cumulative.report,fiscalyear:0
334msgid "Fiscal year"
335msgstr "Ejercicio fiscal"
336
337#. module: fl_account_financial_report
338#: field:fl.account.general.ledger.cumulative.report,landscape:0
339msgid "Landscape Mode"
340msgstr "Modo apaisado"
341
342#. module: fl_account_financial_report
343#: field:fl.account.general.ledger.cumulative.report,display_account:0
344msgid "Display accounts"
345msgstr "Mostrar cuentas"
346
347#. module: fl_account_financial_report
348#: field:fl.account.balance.full.report,display_account_level:0
349msgid "Up to level"
350msgstr "Hasta el nivel"
351
352#. module: fl_account_financial_report
353#: view:fl.account.balance.full.report:0
354#: view:fl.account.general.ledger.cumulative.report:0
355msgid "Cancel"
356msgstr "Cancelar"
357
358#. module: fl_account_financial_report
359#: help:fl.account.balance.full.report,fiscalyear:0
360msgid "Keep empty to use all open fiscal years to compute the balance"
361msgstr "Dejarlo vacio para usar todos los ejercicios fiscales abiertos para calcular el balance"
362
363#. module: fl_account_financial_report
364#: selection:fl.account.general.ledger.cumulative.report,states:0
365msgid "Account Selection"
366msgstr "Selección de cuenta"
367
0368
=== added directory 'account_financial_report_web/report'
=== added file 'account_financial_report_web/report/__init__.py'
--- account_financial_report_web/report/__init__.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/report/__init__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,25 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Factor Libre (http://factorlibre.com) All Rights Reserved.
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21import account_balance
22import general_ledger
23import general_ledger_landscape
24import rml_parse
25
026
=== added file 'account_financial_report_web/report/account_balance.py'
--- account_financial_report_web/report/account_balance.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/report/account_balance.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,314 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
7# Jordi Esteve <jesteve@zikzakmedia.com>
8# $Id$
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU Affero General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU Affero General Public License for more details.
19#
20# You should have received a copy of the GNU Affero General Public License
21# along with this program. If not, see <http://www.gnu.org/licenses/>.
22#
23##############################################################################
24
25import xml
26import copy
27from operator import itemgetter
28import time
29import datetime
30from report import report_sxw
31from tools import config
32#import decimal_precision as dp
33
34#import sys
35
36class account_balance(report_sxw.rml_parse):
37 _name = "report.account.balance.full2"
38
39
40 def __init__(self, cr, uid, name, context):
41 super(account_balance, self).__init__(cr, uid, name, context)
42 self.sum_debit = 0.00
43 self.sum_credit = 0.00
44 self.sum_balance = 0.00
45 self.sum_debit_fy = 0.00
46 self.sum_credit_fy = 0.00
47 self.sum_balance_fy = 0.00
48 self.date_lst = []
49 self.date_lst_string = ''
50 self.localcontext.update({
51 'time': time,
52 'lines': self.lines,
53 'get_fiscalyear_text': self.get_fiscalyear_text,
54 'get_periods_and_date_text': self.get_periods_and_date_text,
55 })
56 self.context = context
57
58
59
60 def set_context(self, objects, data, ids, report_type=None):
61 new_ids = ids
62
63 if (data['model'] == 'ir.ui.menu'):
64 new_ids = data['form']['account_list']
65 objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
66 super(account_balance, self).set_context(objects, data, new_ids, report_type=report_type)
67
68 def get_fiscalyear_text(self, form):
69 """
70 Returns the fiscal year text used on the report.
71 """
72 fiscalyear_obj = self.pool.get('account.fiscalyear')
73 fiscalyear = None
74
75 if form.get('fiscalyear'):
76
77 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'][0])
78
79 return fiscalyear.name or fiscalyear.code
80 else:
81 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid))
82 return "%s*" % (fiscalyear.name or fiscalyear.code)
83
84
85 def get_periods_and_date_text(self, form):
86 """
87 Returns the text with the periods/dates used on the report.
88 """
89 period_obj = self.pool.get('account.period')
90 periods_str = None
91 fiscalyear_id = form['fiscalyear'] or fiscalyear_obj.find(self.cr, self.uid)
92 period_ids = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear_id[0]),('special','=',False)])
93 if form['state'] in ['byperiod', 'all']:
94 period_ids = form['periods']
95 periods_str = ', '.join([period.name or period.code for period in period_obj.browse(self.cr, self.uid, period_ids)])
96
97 dates_str = None
98 if form['state'] in ['bydate', 'all']:
99 dates_str = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
100
101 if periods_str and dates_str:
102 return "%s / %s" % (periods_str, dates_str)
103 elif periods_str:
104 return "%s" % periods_str
105 elif dates_str:
106 return "%s" % dates_str
107 else:
108 return ''
109
110
111 def lines(self, form, ids={}, done=None, level=0):
112 """
113 Returns all the data needed for the report lines
114 (account info plus debit/credit/balance in the selected period
115 and the full year)
116 """
117
118 if not ids:
119 ids = self.ids
120 if not ids:
121 return []
122 if not done:
123 done = {}
124 if form.has_key('account_list') and form['account_list']:
125 account_ids = form['account_list']
126 del form['account_list']
127 res = {}
128 result_acc = []
129 accounts_levels = {}
130 account_obj = self.pool.get('account.account')
131 period_obj = self.pool.get('account.period')
132 fiscalyear_obj = self.pool.get('account.fiscalyear')
133
134 # Get the fiscal year
135 fiscalyear = None
136 if form.get('fiscalyear'):
137 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, form['fiscalyear'][0])
138 else:
139 fiscalyear = fiscalyear_obj.browse(self.cr, self.uid, fiscalyear_obj.find(self.cr, self.uid))
140
141 #
142 # Get the accounts
143 #
144 child_ids = account_obj._get_children_and_consol(self.cr, self.uid, account_ids, self.context)
145 if child_ids:
146 account_ids = child_ids
147
148 #
149 # Calculate the FY Balance.
150 # (from full fiscal year without closing periods)
151 #
152 ctx = self.context.copy()
153
154 if form.get('fiscalyear'):
155 # Use only the current fiscal year
156 ctx['fiscalyear'] = fiscalyear.id
157 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)])
158 else:
159 # Use all the open fiscal years
160 open_fiscalyear_ids = fiscalyear_obj.search(self.cr, self.uid, [('state','=','draft')])
161 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','in',open_fiscalyear_ids),'|',('special','=',False),('date_stop','<',fiscalyear.date_stop)])
162
163 fy_balance = {}
164 for acc in account_obj.read(self.cr, self.uid, account_ids, ['balance'], ctx):
165 fy_balance[acc['id']] = acc['balance']
166
167 #
168 # Calculate the FY Debit/Credit
169 # (from full fiscal year without opening or closing periods)
170 #
171 ctx = self.context.copy()
172 ctx['fiscalyear'] = fiscalyear.id
173 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
174
175 fy_debit = {}
176 fy_credit = {}
177 for acc in account_obj.read(self.cr, self.uid, account_ids, ['debit','credit','balance'], ctx):
178 fy_debit[acc['id']] = acc['debit']
179 fy_credit[acc['id']] = acc['credit']
180
181 #
182 # Calculate the period Debit/Credit
183 # (from the selected period or all the non special periods in the fy)
184 #
185 ctx = self.context.copy()
186 """tx['state'] = form['context'].get('state','all')"""
187 ctx['fiscalyear'] = fiscalyear.id
188 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
189 if form['state'] in ['byperiod', 'all']:
190 ctx['periods'] = form['periods']
191 if form['state'] in ['bydate', 'all']:
192 ctx['date_from'] = form['date_from']
193 ctx['date_to'] = form['date_to']
194
195 accounts = account_obj.read(self.cr, self.uid, account_ids, ['type','code','name','debit','credit','balance','parent_id'], ctx)
196 # In some versions of OpenERP server, the order of the read records differs from the order of the ids of the records
197 accounts.sort(lambda x,y: cmp(x['code'], y['code']))
198
199 #
200 # Calculate the period initial Balance
201 # (fy balance minus the balance from the start of the selected period
202 # to the end of the year)
203 #
204 ctx = self.context.copy()
205 """ctx['state'] = form['context'].get('state','all')"""
206 ctx['fiscalyear'] = fiscalyear.id
207 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('special','=',False)])
208 if form['state'] in ['byperiod', 'all']:
209 ctx['periods'] = form['periods']
210 date_start = min([period.date_start for period in period_obj.browse(self.cr, self.uid, ctx['periods'])])
211 ctx['periods'] = period_obj.search(self.cr, self.uid, [('fiscalyear_id','=',fiscalyear.id),('date_start','>=',date_start),('special','=',False)])
212 if form['state'] in ['bydate', 'all']:
213 ctx['date_from'] = form['date_from']
214 ctx['date_to'] = fiscalyear.date_stop
215
216 period_balanceinit = {}
217 for acc in account_obj.read(self.cr, self.uid, account_ids, ['balance'], ctx):
218 period_balanceinit[acc['id']] = fy_balance[acc['id']] - acc['balance']
219
220 #
221 # Generate the report lines (checking each account)
222 #
223 decimal_precision_obj = self.pool.get('decimal.precision')
224 ids = decimal_precision_obj.search(self.cr, self.uid, [('name', '=', 'Account')])
225 digits = decimal_precision_obj.browse(self.cr, self.uid, ids)[0].digits
226 #print >>sys.stderr, 'digits',digits
227
228 for account in accounts:
229 account_id = account['id']
230
231 if account_id in done:
232 continue
233
234 done[account_id] = 1
235
236 #
237 # Calculate the account level
238 #
239 parent_id = account['parent_id']
240 if parent_id:
241 if isinstance(parent_id, tuple):
242 parent_id = parent_id[0]
243 account_level = accounts_levels.get(parent_id, 0) + 1
244 else:
245 account_level = level
246 accounts_levels[account_id] = account_level
247
248 #
249 # Check if we need to include this level
250 #
251 if not form['display_account_level'] or account_level <= form['display_account_level']:
252 #
253 # Copy the account values
254 #
255 res = {
256 'id' : account_id,
257 'type' : account['type'],
258 'code': account['code'],
259 'name': account['name'],
260 'level': account_level,
261 'balanceinit': period_balanceinit[account_id],
262 'debit': account['debit'],
263 'credit': account['credit'],
264 'balance': period_balanceinit[account_id]+account['balance'],
265 'balanceinit_fy': fy_balance[account_id]-fy_debit[account_id]+fy_credit[account_id],
266 'debit_fy': fy_debit[account_id],
267 'credit_fy': fy_credit[account_id],
268 'balance_fy': fy_balance[account_id],
269 'parent_id': account['parent_id'],
270 'bal_type': '',
271 }
272
273 #
274 # Round the values to zero if needed (-0.000001 ~= 0)
275 #
276 res['balance'] = round(res['balance'],digits)
277 res['balance_fy'] = round(res['balance_fy'],digits)
278 res['balanceinit'] = round(res['balanceinit'],digits)
279 res['balanceinit_fy'] = round(res['balanceinit_fy'],digits)
280 res['debit'] = round(res['debit'],digits)
281 res['credit'] = round(res['credit'],digits)
282 #if abs(res['balance']) < 0.5 * 10**-int(config['price_accuracy']):
283 # res['balance'] = 0.0
284 #if abs(res['balance_fy']) < 0.5 * 10**-int(config['price_accuracy']):
285 # res['balance_fy'] = 0.0
286 #if abs(res['balanceinit']) < 0.5 * 10**-int(config['price_accuracy']):
287 # res['balanceinit'] = 0.0
288 #if abs(res['balanceinit_fy']) < 0.5 * 10**-int(config['price_accuracy']):
289 # res['balanceinit_fy'] = 0.0
290
291 #
292 # Check whether we must include this line in the report or not
293 #
294 if form['display_account'] == 'bal_mouvement' and account['parent_id']:
295 # Include accounts with movements
296 if res['balance'] <> 0.0 \
297 or res['debit'] <> 0.0 \
298 or res['credit'] <> 0.0:
299 # if abs(res['balance']) >= 0.5 * 10**-int(config['price_accuracy']) \
300 # or abs(res['credit']) >= 0.5 * 10**-int(config['price_accuracy']) \
301 # or abs(res['debit']) >= 0.5 * 10**-int(config['price_accuracy']):
302 result_acc.append(res)
303 elif form['display_account'] == 'bal_solde' and account['parent_id']:
304 # Include accounts with balance
305 #if abs(res['balance']) >= 0.5 * 10**-int(config['price_accuracy']):
306 if res['balance'] <> 0.0 :
307 result_acc.append(res)
308 else:
309 # Include all accounts
310 result_acc.append(res)
311 return result_acc
312
313report_sxw.report_sxw('report.account.balance.full2', 'account.account', 'addons/account_financial_report/report/account_balance_full.rml', parser=account_balance, header=False)
314# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0315
=== added file 'account_financial_report_web/report/general_ledger.py'
--- account_financial_report_web/report/general_ledger.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/report/general_ledger.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,412 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Copyright (c) 2005-2006 CamptoCamp
5# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
6# Jordi Esteve <jesteve@zikzakmedia.com>
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsability of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs
11# End users who are looking for a ready-to-use solution with commercial
12# garantees and support are strongly adviced to contract a Free Software
13# Service Company
14#
15# This program is Free Software; you can redistribute it and/or
16# modify it under the terms of the GNU Affero General Public License
17# as published by the Free Software Foundation; either version 2
18# of the License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program; if not, write to the Free Software
27# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28#
29##############################################################################
30
31import time
32from report import report_sxw
33from tools import config
34from tools.translate import _
35import rml_parse
36
37class general_ledger(rml_parse.rml_parse):
38 _name = 'report.account.general.ledger.cumulative2'
39
40 def set_context(self, objects, data, ids, report_type = None):
41 self.get_context_date_period(data['form'])
42 new_ids = []
43 if (data['model'] == 'account.account'):
44 new_ids = ids
45 else:
46 new_ids = data['form']['account_list']
47 objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
48 super(general_ledger, self).set_context(objects, data, new_ids, report_type)
49
50
51 def __init__(self, cr, uid, name, context):
52 super(general_ledger, self).__init__(cr, uid, name, context=context)
53 self.query = "" # SQL query to get account moves for given date or period
54 self.min_date = "" # Min date of the given date or period
55 self.ctx = {} # Context for given date or period
56 self.ctxfy = {} # Context from the date start or first period of the fiscal year
57 self.child_ids = ""
58 self.tot_currency = 0.0
59 self.balance_accounts = {}
60 self.localcontext.update( {
61 'time': time,
62 'lines': self.lines,
63 'sum_debit_account': self._sum_debit_account,
64 'sum_credit_account': self._sum_credit_account,
65 'sum_balance_account': self._sum_balance_account,
66 'get_children_accounts': self.get_children_accounts,
67 'sum_currency_amount_account': self._sum_currency_amount_account,
68 'get_fiscalyear':self.get_fiscalyear,
69 'get_periods':self.get_periods,
70 })
71 self.context = context
72
73
74 def get_fiscalyear(self, form):
75 res=[]
76 if form.has_key('fiscalyear'):
77 fisc_id = form['fiscalyear'][0]
78 if not (fisc_id):
79 return ''
80 self.cr.execute("SELECT name FROM account_fiscalyear WHERE id = %s" , (int(fisc_id),))
81 res=self.cr.fetchone()
82 return res and res[0] or ''
83
84
85 def get_periods(self, form):
86 result=''
87 if form.has_key('periods') and form['periods']:
88 period_ids = ",".join([str(x) for x in form['periods'] if x])
89 self.cr.execute("SELECT name FROM account_period WHERE id in (%s)" % (period_ids))
90 res = self.cr.fetchall()
91 len_res = len(res)
92 for r in res:
93 if (r == res[len_res-1]):
94 result+=r[0]+". "
95 else:
96 result+=r[0]+", "
97 elif form.has_key('date_from') and form.has_key('date_to'):
98 result = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
99 else:
100 fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear'][0])
101 res = fy_obj.period_ids
102 len_res = len(res)
103 for r in res:
104 if r == res[len_res-1]:
105 result+=r.name+". "
106 else:
107 result+=r.name+", "
108
109 return str(result and result[:-1]) or ''
110
111
112 def _calc_contrepartie(self, cr, uid, ids, context={}):
113 result = {}
114 #for id in ids:
115 # result.setdefault(id, False)
116 for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context):
117 # For avoid long text in the field we will limit it to 5 lines
118 #
119 result[account_line.id] = ' '
120 num_id_move = str(account_line.move_id.id)
121 num_id_line = str(account_line.id)
122 account_id = str(account_line.account_id.id)
123 # search the basic account
124 # We have the account ID we will search all account move line from now until this time
125 # We are in the case of we are on the top of the account move Line
126 cr.execute("SELECT distinct(ac.code) as code_rest,ac.name as name_rest "\
127 "FROM account_account AS ac, account_move_line mv "\
128 "WHERE ac.id = mv.account_id and mv.move_id = " + num_id_move + " and mv.account_id <> " + account_id )
129 res_mv = cr.dictfetchall()
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
131 if (len(res_mv) >=1):
132 concat = ''
133 rup_id = 0
134 for move_rest in res_mv:
135 concat = concat + move_rest['code_rest'] + '|'
136 result[account_line.id] = concat
137 if rup_id >5:
138 # we need to stop the computing and to escape but before we will add "..."
139 result[account_line.id] = concat + '...'
140 break
141 rup_id+=1
142 return result
143
144
145 def get_context_date_period(self, form):
146 date_min = period_min = False
147
148 # ctx: Context for the given date or period
149 ctx = self.context.copy()
150 if 'fiscalyear' in form and form['fiscalyear']:
151 ctx['fiscalyear'] = form['fiscalyear'][0]
152 if form['state'] in ['byperiod', 'all']:
153 ctx['periods'] = form['periods']
154 if form['state'] in ['bydate', 'all']:
155 ctx['date_from'] = form['date_from']
156 ctx['date_to'] = form['date_to']
157 if 'periods' not in ctx:
158 ctx['periods'] = []
159 self.ctx = ctx
160 print ctx
161 self.query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
162 # ctxfy: Context from the date start / first period of the fiscal year
163 ctxfy = ctx.copy()
164 ctxfy['periods'] = ctx['periods'][:]
165
166 if form['state'] in ['byperiod', 'all'] and len(ctx['periods']):
167 self.cr.execute("""SELECT id, date_start, fiscalyear_id
168 FROM account_period
169 WHERE date_start = (SELECT min(date_start) FROM account_period WHERE id in (%s))"""
170 % (','.join([str(x) for x in ctx['periods']])))
171 res = self.cr.dictfetchone()
172 period_min = res['date_start']
173 self.cr.execute("""SELECT id
174 FROM account_period
175 WHERE fiscalyear_id in (%s) AND date_start < '%s'"""
176 % (res['fiscalyear_id'], res['date_start']))
177 ids = filter(None, map(lambda x:x[0], self.cr.fetchall()))
178 ctxfy['periods'].extend(ids)
179
180 if form['state'] in ['bydate', 'all']:
181 self.cr.execute("""SELECT date_start
182 FROM account_fiscalyear
183 WHERE '%s' BETWEEN date_start AND date_stop""" % (ctx['date_from']))
184 res = self.cr.dictfetchone()
185 ctxfy['date_from'] = res['date_start']
186 date_min = form['date_from']
187
188 if form['state'] == 'none' or (form['state'] == 'byperiod' and not len(ctx['periods'])):
189 if 'fiscalyear' in form and form['fiscalyear']:
190 sql = """SELECT id, date_start
191 FROM account_period
192 WHERE fiscalyear_id in (%s)
193 ORDER BY date_start""" % (ctx['fiscalyear'])
194 else:
195 sql = """SELECT id, date_start
196 FROM account_period
197 WHERE fiscalyear_id in (SELECT id FROM account_fiscalyear WHERE state='draft')
198 ORDER BY date_start"""
199 self.cr.execute(sql)
200 res = self.cr.dictfetchall()
201 period_min = res[0]['date_start']
202 ids = filter(None, map(lambda x:x['id'], res))
203 ctxfy['periods'] = ids
204 self.ctxfy = ctxfy
205
206 if not period_min:
207 self.min_date = date_min
208 elif not date_min:
209 self.min_date = period_min
210 else:
211 # If period and date are given, the maximum of the min dates is choosed
212 if period_min < date_min:
213 self.min_date = date_min
214 else:
215 self.min_date = period_min
216
217
218 def get_children_accounts(self, account, form):
219 move_line_obj = self.pool.get('account.move.line')
220 account_obj = self.pool.get('account.account')
221 invoice_obj = self.pool.get('account.invoice')
222 self.child_ids = account_obj.search(self.cr, self.uid, [('parent_id', 'child_of', form['account_list'])])
223 res = []
224 ctx = self.ctx.copy()
225 if account and account.child_consol_ids: # add ids of consolidated childs also of selected account
226 ctx['consolidate_childs'] = True
227 ctx['account_id'] = account.id
228 ids_acc = account_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account.id])], context=ctx)
229 for child_id in ids_acc:
230 child_account = account_obj.browse(self.cr, self.uid, child_id)
231 balance_account = self._sum_balance_account(child_account,form)
232 self.balance_accounts[child_account.id] = balance_account
233 if form['display_account'] == 'bal_mouvement':
234 if child_account.type != 'view' \
235 and len(move_line_obj.search(self.cr, self.uid,
236 [('account_id','=',child_account.id)],
237 context=ctx)) <> 0 :
238 res.append(child_account)
239 elif form['display_account'] == 'bal_solde':
240 if child_account.type != 'view' \
241 and len(move_line_obj.search(self.cr, self.uid,
242 [('account_id','=',child_account.id)],
243 context=ctx)) <> 0 :
244 if balance_account <> 0.0:
245 res.append(child_account)
246 else:
247 if child_account.type != 'view' \
248 and len(move_line_obj.search(self.cr, self.uid,
249 [('account_id','>=',child_account.id)],
250 context=ctx)) <> 0 :
251 res.append(child_account)
252 ##
253 if not len(res):
254 return [account]
255 else:
256 ## We will now compute initial balance
257 for move in res:
258 sql_balance_init = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit "\
259 "FROM account_move_line l "\
260 "WHERE l.account_id = " + str(move.id) + " AND %s" % (self.query)
261 self.cr.execute(sql_balance_init)
262 resultat = self.cr.dictfetchall()
263 if resultat[0] :
264 if resultat[0]['sum_debit'] == None:
265 sum_debit = 0
266 else:
267 sum_debit = resultat[0]['sum_debit']
268 if resultat[0]['sum_credit'] == None:
269 sum_credit = 0
270 else:
271 sum_credit = resultat[0]['sum_credit']
272
273 move.init_credit = sum_credit
274 move.init_debit = sum_debit
275 else:
276 move.init_credit = 0
277 move.init_debit = 0
278 return res
279
280
281 def lines(self, account, form):
282 inv_types = {
283 'out_invoice': _('CI: '),
284 'in_invoice': _('SI: '),
285 'out_refund': _('OR: '),
286 'in_refund': _('SR: '),
287 }
288
289 self.query
290
291 if form['sortbydate'] == 'sort_date':
292 sorttag = 'l.date'
293 else:
294 sorttag = 'j.code'
295 sql = """
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
297 FROM account_move_line as l
298 LEFT JOIN res_currency c on (l.currency_id=c.id)
299 JOIN account_journal j on (l.journal_id=j.id)
300 AND account_id = %%s
301 AND %s
302 ORDER by %s""" % (self.query, sorttag)
303 self.cr.execute(sql % account.id)
304
305 res = self.cr.dictfetchall()
306 move_line_obj = self.pool.get('account.move.line')
307 account_obj = self.pool.get('account.account')
308 invoice_obj = self.pool.get('account.invoice')
309
310 # Balance from init fiscal year to last date given by the user
311 accounts = account_obj.read(self.cr, self.uid, [account.id], ['balance'], self.ctxfy)
312 sum = accounts[0]['balance']
313
314 for l in reversed(res):
315 line = move_line_obj.browse(self.cr, self.uid, l['id'])
316 l['move'] = line.move_id.name_split
317 self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id))
318 tmpres = self.cr.dictfetchall()
319 if len(tmpres) > 0 :
320 inv = invoice_obj.browse(self.cr, self.uid, tmpres[0]['id'])
321 l['ref'] = inv_types[inv.type] + ': '+str(inv.number)
322 if line.partner_id :
323 l['partner'] = line.partner_id.name
324 else :
325 l['partner'] = ''
326 l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']]
327
328 # Cumulative balance update
329 l['progress'] = sum
330 sum = sum - l['debit'] + l ['credit']
331
332 # Modification of currency amount
333 if (l['credit'] > 0):
334 if l['amount_currency'] != None:
335 l['amount_currency'] = abs(l['amount_currency']) * -1
336 if l['amount_currency'] != None:
337 self.tot_currency = self.tot_currency + l['amount_currency']
338
339 decimal_precision_obj = self.pool.get('decimal.precision')
340 ids = decimal_precision_obj.search(self.cr, self.uid, [('name', '=', 'Account')])
341 digits = decimal_precision_obj.browse(self.cr, self.uid, ids)[0].digits
342
343 #if abs(sum) > 10**-int(config['price_accuracy']) and form['initial_balance']:
344 if round(sum,digits) <> 0.0 and form['initial_balance']:
345 res.insert(0, {
346 'date': self.min_date,
347 'name': _('Initial balance'),
348 'progress': sum,
349 'partner': '',
350 'move': '',
351 'ref': '',
352 'debit': '',
353 'credit': '',
354 'amount_currency': '',
355 'currency_code': '',
356 'code': '',
357 'line_corresp': '',
358 })
359
360 return res
361
362
363 def _sum_debit_account(self, account, form):
364 self.cr.execute("SELECT sum(debit) "\
365 "FROM account_move_line l "\
366 "WHERE l.account_id = %s AND %s " % (account.id, self.query))
367 sum_debit = self.cr.fetchone()[0] or 0.0
368 return sum_debit
369
370
371 def _sum_credit_account(self, account, form):
372 self.cr.execute("SELECT sum(credit) "\
373 "FROM account_move_line l "\
374 "WHERE l.account_id = %s AND %s " % (account.id, self.query))
375 sum_credit = self.cr.fetchone()[0] or 0.0
376 return sum_credit
377
378
379 def _sum_balance_account(self, account, form):
380 # Balance from init fiscal year to last date given by the user
381 accounts = self.pool.get('account.account').read(self.cr, self.uid, [account.id], ['balance'], self.ctxfy)
382 sum_balance = accounts[0]['balance']
383 return sum_balance
384
385
386 def _set_get_account_currency_code(self, account_id):
387 self.cr.execute("SELECT c.symbol as code "\
388 "FROM res_currency c, account_account as ac "\
389 "WHERE ac.id = %s AND ac.currency_id = c.id" % (account_id))
390 result = self.cr.fetchone()
391 if result:
392 self.account_currency = result[0]
393 else:
394 self.account_currency = False
395
396
397 def _sum_currency_amount_account(self, account, form):
398 self._set_get_account_currency_code(account.id)
399 self.cr.execute("SELECT sum(l.amount_currency) "\
400 "FROM account_move_line as l, res_currency as rc "\
401 "WHERE l.currency_id = rc.id AND l.account_id= %s AND %s" % (account.id, self.query))
402 total = self.cr.fetchone()
403 if self.account_currency:
404 return_field = str(total[0]) + self.account_currency
405 return return_field
406 else:
407 currency_total = self.tot_currency = 0.0
408 return currency_total
409
410
411report_sxw.report_sxw('report.account.general.ledger.cumulative2', 'account.account', 'addons/account_financial_report/report/general_ledger.rml', parser=general_ledger, header=False)
412# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0413
=== added file 'account_financial_report_web/report/general_ledger_landscape.py'
--- account_financial_report_web/report/general_ledger_landscape.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/report/general_ledger_landscape.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,413 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Copyright (c) 2005-2006 CamptoCamp
5# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
6# Jordi Esteve <jesteve@zikzakmedia.com>
7#
8# WARNING: This program as such is intended to be used by professional
9# programmers who take the whole responsability of assessing all potential
10# consequences resulting from its eventual inadequacies and bugs
11# End users who are looking for a ready-to-use solution with commercial
12# garantees and support are strongly adviced to contract a Free Software
13# Service Company
14#
15# This program is Free Software; you can redistribute it and/or
16# modify it under the terms of the GNU Affero General Public License
17# as published by the Free Software Foundation; either version 2
18# of the License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU Affero General Public License for more details.
24#
25# You should have received a copy of the GNU Affero General Public License
26# along with this program; if not, write to the Free Software
27# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28#
29##############################################################################
30
31
32import time
33from report import report_sxw
34from tools.translate import _
35import rml_parse
36
37
38class general_ledger_landscape(rml_parse.rml_parse):
39 _name = 'report.account.general.ledger.cumulative.landscape2'
40
41 def set_context(self, objects, data, ids, report_type = None):
42 self.get_context_date_period(data['form'])
43 new_ids = []
44 if (data['model'] == 'account.account'):
45 new_ids = ids
46 else:
47 new_ids = data['form']['account_list']
48 objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids)
49 super(general_ledger_landscape, self).set_context(objects, data, new_ids, report_type)
50
51
52 def __init__(self, cr, uid, name, context):
53 super(general_ledger_landscape, self).__init__(cr, uid, name, context=context)
54 self.query = "" # SQL query to get account moves for given date or period
55 self.min_date = "" # Min date of the given date or period
56 self.ctx = {} # Context for given date or period
57 self.ctxfy = {} # Context from the date start or first period of the fiscal year
58 self.child_ids = ""
59 self.tot_currency = 0.0
60 self.balance_accounts = {}
61 self.localcontext.update( {
62 'time': time,
63 'lines': self.lines,
64 'sum_debit_account': self._sum_debit_account,
65 'sum_credit_account': self._sum_credit_account,
66 'sum_balance_account': self._sum_balance_account,
67 'get_children_accounts': self.get_children_accounts,
68 'sum_currency_amount_account': self._sum_currency_amount_account,
69 'get_fiscalyear':self.get_fiscalyear,
70 'get_periods':self.get_periods,
71 })
72 self.context = context
73
74
75 def get_fiscalyear(self, form):
76 res=[]
77 if form.has_key('fiscalyear'):
78 fisc_id = form['fiscalyear'][0]
79 if not (fisc_id):
80 return ''
81 self.cr.execute("SELECT name FROM account_fiscalyear WHERE id = %s" , (int(fisc_id),))
82 res=self.cr.fetchone()
83 return res and res[0] or ''
84
85
86 def get_periods(self, form):
87 result=''
88 if form.has_key('periods') and form['periods']:
89 period_ids = ",".join([str(x) for x in form['periods']if x])
90 self.cr.execute("SELECT name FROM account_period WHERE id in (%s)" % (period_ids))
91 res = self.cr.fetchall()
92 len_res = len(res)
93 for r in res:
94 if (r == res[len_res-1]):
95 result+=r[0]+". "
96 else:
97 result+=r[0]+", "
98 elif form.has_key('date_from') and form.has_key('date_to'):
99 result = self.formatLang(form['date_from'], date=True) + ' - ' + self.formatLang(form['date_to'], date=True) + ' '
100 else:
101 fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear'])
102 res = fy_obj.period_ids
103 len_res = len(res)
104 for r in res:
105 if r == res[len_res-1]:
106 result+=r.name+". "
107 else:
108 result+=r.name+", "
109
110 return str(result and result[:-1]) or ''
111
112
113 def _calc_contrepartie(self, cr, uid, ids, context={}):
114 result = {}
115 #for id in ids:
116 # result.setdefault(id, False)
117
118 for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context):
119 # For avoid long text in the field we will limit it to 5 lines
120 #
121 result[account_line.id] = ' '
122 num_id_move = str(account_line.move_id.id)
123 num_id_line = str(account_line.id)
124 account_id = str(account_line.account_id.id)
125 # search the basic account
126 # We have the account ID we will search all account move line from now until this time
127 # We are in the case of we are on the top of the account move Line
128 cr.execute("SELECT distinct(ac.code) as code_rest,ac.name as name_rest "\
129 "FROM account_account AS ac, account_move_line mv "\
130 "WHERE ac.id = mv.account_id and mv.move_id = " + num_id_move + " and mv.account_id <> " + account_id )
131 res_mv = cr.dictfetchall()
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
133 if (len(res_mv) >=1):
134 concat = ''
135 rup_id = 0
136 for move_rest in res_mv:
137 concat = concat + move_rest['code_rest'] + '|'
138 result[account_line.id] = concat
139 if rup_id >5:
140 # we need to stop the computing and to escape but before we will add "..."
141 result[account_line.id] = concat + '...'
142 break
143 rup_id+=1
144 return result
145
146
147 def get_context_date_period(self, form):
148 date_min = period_min = False
149
150 # ctx: Context for the given date or period
151 ctx = self.context.copy()
152 if 'fiscalyear' in form and form['fiscalyear']:
153 ctx['fiscalyear'] = form['fiscalyear'][0]
154 if form['state'] in ['byperiod', 'all']:
155 ctx['periods'] = form['periods']
156 if form['state'] in ['bydate', 'all']:
157 ctx['date_from'] = form['date_from']
158 ctx['date_to'] = form['date_to']
159 if 'periods' not in ctx:
160 ctx['periods'] = []
161 self.ctx = ctx
162 self.query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
163
164 # ctxfy: Context from the date start / first period of the fiscal year
165 ctxfy = ctx.copy()
166 ctxfy['periods'] = ctx['periods'][:]
167
168 if form['state'] in ['byperiod', 'all'] and len(ctx['periods']):
169 self.cr.execute("""SELECT id, date_start, fiscalyear_id
170 FROM account_period
171 WHERE date_start = (SELECT min(date_start) FROM account_period WHERE id in (%s))"""
172 % (','.join([str(x) for x in ctx['periods']])))
173 res = self.cr.dictfetchone()
174 period_min = res['date_start']
175 self.cr.execute("""SELECT id
176 FROM account_period
177 WHERE fiscalyear_id in (%s) AND date_start < '%s'"""
178 % (res['fiscalyear_id'], res['date_start']))
179 ids = filter(None, map(lambda x:x[0], self.cr.fetchall()))
180 ctxfy['periods'].extend(ids)
181
182 if form['state'] in ['bydate', 'all']:
183 self.cr.execute("""SELECT date_start
184 FROM account_fiscalyear
185 WHERE '%s' BETWEEN date_start AND date_stop""" % (ctx['date_from']))
186 res = self.cr.dictfetchone()
187 ctxfy['date_from'] = res['date_start']
188 date_min = form['date_from']
189
190 if form['state'] == 'none' or (form['state'] == 'byperiod' and not len(ctx['periods'])):
191 if 'fiscalyear' in form and form['fiscalyear']:
192 sql = """SELECT id, date_start
193 FROM account_period
194 WHERE fiscalyear_id in (%s)
195 ORDER BY date_start""" % (ctx['fiscalyear'])
196 else:
197 sql = """SELECT id, date_start
198 FROM account_period
199 WHERE fiscalyear_id in (SELECT id FROM account_fiscalyear WHERE state='draft')
200 ORDER BY date_start"""
201 self.cr.execute(sql)
202 res = self.cr.dictfetchall()
203 period_min = res[0]['date_start']
204 ids = filter(None, map(lambda x:x['id'], res))
205 ctxfy['periods'] = ids
206 self.ctxfy = ctxfy
207
208 if not period_min:
209 self.min_date = date_min
210 elif not date_min:
211 self.min_date = period_min
212 else:
213 # If period and date are given, the maximum of the min dates is choosed
214 if period_min < date_min:
215 self.min_date = date_min
216 else:
217 self.min_date = period_min
218
219
220 def get_children_accounts(self, account, form):
221 move_line_obj = self.pool.get('account.move.line')
222 account_obj = self.pool.get('account.account')
223 invoice_obj = self.pool.get('account.invoice')
224 self.child_ids = account_obj.search(self.cr, self.uid, [('parent_id', 'child_of', form['account_list'])])
225
226 res = []
227 ctx = self.ctx.copy()
228 if account and account.child_consol_ids: # add ids of consolidated childs also of selected account
229 ctx['consolidate_childs'] = True
230 ctx['account_id'] = account.id
231 ids_acc = account_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account.id])], context=ctx)
232 for child_id in ids_acc:
233 child_account = account_obj.browse(self.cr, self.uid, child_id)
234 balance_account = self._sum_balance_account(child_account,form)
235 self.balance_accounts[child_account.id] = balance_account
236 if form['display_account'] == 'bal_mouvement':
237 if child_account.type != 'view' \
238 and len(move_line_obj.search(self.cr, self.uid,
239 [('account_id','=',child_account.id)],
240 context=ctx)) <> 0 :
241 res.append(child_account)
242 elif form['display_account'] == 'bal_solde':
243 if child_account.type != 'view' \
244 and len(move_line_obj.search(self.cr, self.uid,
245 [('account_id','=',child_account.id)],
246 context=ctx)) <> 0 :
247 if balance_account <> 0.0:
248 res.append(child_account)
249 else:
250 if child_account.type != 'view' \
251 and len(move_line_obj.search(self.cr, self.uid,
252 [('account_id','>=',child_account.id)],
253 context=ctx)) <> 0 :
254 res.append(child_account)
255 ##
256 if not len(res):
257 return [account]
258 else:
259 ## We will now compute initial balance
260 for move in res:
261 sql_balance_init = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit "\
262 "FROM account_move_line l "\
263 "WHERE l.account_id = " + str(move.id) + " AND %s" % (self.query)
264 self.cr.execute(sql_balance_init)
265 resultat = self.cr.dictfetchall()
266 if resultat[0] :
267 if resultat[0]['sum_debit'] == None:
268 sum_debit = 0
269 else:
270 sum_debit = resultat[0]['sum_debit']
271 if resultat[0]['sum_credit'] == None:
272 sum_credit = 0
273 else:
274 sum_credit = resultat[0]['sum_credit']
275
276 move.init_credit = sum_credit
277 move.init_debit = sum_debit
278 else:
279 move.init_credit = 0
280 move.init_debit = 0
281 return res
282
283
284 def lines(self, account, form):
285 inv_types = {
286 'out_invoice': _('CI: '),
287 'in_invoice': _('SI: '),
288 'out_refund': _('OR: '),
289 'in_refund': _('SR: '),
290 }
291
292 if form['sortbydate'] == 'sort_date':
293 sorttag = 'l.date'
294 else:
295 sorttag = 'j.code'
296 sql = """
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
298 FROM account_move_line as l
299 LEFT JOIN res_currency c on (l.currency_id=c.id)
300 JOIN account_journal j on (l.journal_id=j.id)
301 AND account_id = %%s
302 AND %s
303 ORDER by %s""" % (self.query, sorttag)
304 self.cr.execute(sql % account.id)
305
306 res = self.cr.dictfetchall()
307 move_line_obj = self.pool.get('account.move.line')
308 account_obj = self.pool.get('account.account')
309 invoice_obj = self.pool.get('account.invoice')
310
311 # Balance from init fiscal year to last date given by the user
312 accounts = account_obj.read(self.cr, self.uid, [account.id], ['balance'], self.ctxfy)
313 sum = accounts[0]['balance']
314
315 for l in reversed(res):
316 line = move_line_obj.browse(self.cr, self.uid, l['id'])
317 l['move'] = line.move_id.name_split
318 self.cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id))
319 tmpres = self.cr.dictfetchall()
320 if len(tmpres) > 0 :
321 inv = invoice_obj.browse(self.cr, self.uid, tmpres[0]['id'])
322 l['ref'] = inv_types[inv.type] + ': '+str(inv.number)
323 if line.partner_id :
324 l['partner'] = line.partner_id.name
325 else :
326 l['partner'] = ''
327 l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']]
328
329 # Cumulative balance update
330 l['progress'] = sum
331 sum = sum - (l['debit'] or 0) + (l['credit'] or 0)
332
333 # Modification of currency amount
334 if (l['credit'] > 0):
335 if l['amount_currency'] != None:
336 l['amount_currency'] = abs(l['amount_currency']) * -1
337 if l['amount_currency'] != None:
338 self.tot_currency = self.tot_currency + l['amount_currency']
339
340 decimal_precision_obj = self.pool.get('decimal.precision')
341 ids = decimal_precision_obj.search(self.cr, self.uid, [('name', '=', 'Account')])
342 digits = decimal_precision_obj.browse(self.cr, self.uid, ids)[0].digits
343
344 #if abs(sum) > 10**-int(config['price_accuracy']) and form['initial_balance']:
345 if round(sum,digits) <> 0.0 and form['initial_balance']:
346 res.insert(0, {
347 'date': self.min_date,
348 'name': _('Initial balance'),
349 'progress': sum,
350 'partner': '',
351 'move': '',
352 'ref': '',
353 'debit': '',
354 'credit': '',
355 'amount_currency': '',
356 'currency_code': '',
357 'code': '',
358 'line_corresp': '',
359 })
360
361 return res
362
363
364 def _sum_debit_account(self, account, form):
365 self.cr.execute("SELECT sum(debit) "\
366 "FROM account_move_line l "\
367 "WHERE l.account_id = %s AND %s " % (account.id, self.query))
368 sum_debit = self.cr.fetchone()[0] or 0.0
369 return sum_debit
370
371
372 def _sum_credit_account(self, account, form):
373 self.cr.execute("SELECT sum(credit) "\
374 "FROM account_move_line l "\
375 "WHERE l.account_id = %s AND %s " % (account.id, self.query))
376 sum_credit = self.cr.fetchone()[0] or 0.0
377 return sum_credit
378
379
380 def _sum_balance_account(self, account, form):
381 # Balance from init fiscal year to last date given by the user
382 accounts = self.pool.get('account.account').read(self.cr, self.uid, [account.id], ['balance'], self.ctxfy)
383 sum_balance = accounts[0]['balance']
384 return sum_balance
385
386
387 def _set_get_account_currency_code(self, account_id):
388 self.cr.execute("SELECT c.symbol as code "\
389 "FROM res_currency c, account_account as ac "\
390 "WHERE ac.id = %s AND ac.currency_id = c.id" % (account_id))
391 result = self.cr.fetchone()
392 if result:
393 self.account_currency = result[0]
394 else:
395 self.account_currency = False
396
397
398 def _sum_currency_amount_account(self, account, form):
399 self._set_get_account_currency_code(account.id)
400 self.cr.execute("SELECT sum(l.amount_currency) "\
401 "FROM account_move_line as l, res_currency as rc "\
402 "WHERE l.currency_id = rc.id AND l.account_id= %s AND %s" % (account.id, self.query))
403 total = self.cr.fetchone()
404 if self.account_currency:
405 return_field = str(total[0]) + self.account_currency
406 return return_field
407 else:
408 currency_total = self.tot_currency = 0.0
409 return currency_total
410
411
412report_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)
413# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0414
=== added file 'account_financial_report_web/report/rml_parse.py'
--- account_financial_report_web/report/rml_parse.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/report/rml_parse.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,172 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
6# Jordi Esteve <jesteve@zikzakmedia.com>
7# $Id$
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23
24from report import report_sxw
25import xml.dom.minidom
26import os, time
27import osv
28import re
29import tools
30import pooler
31import re
32import sys
33
34
35class rml_parse(report_sxw.rml_parse):
36
37 def __init__(self, cr, uid, name, context):
38 super(rml_parse, self).__init__(cr, uid, name, context=None)
39 self.localcontext.update({
40 'comma_me': self.comma_me,
41 'format_date': self._get_and_change_date_format_for_swiss,
42 'strip_name' : self._strip_name,
43 'explode_name' : self._explode_name,
44 })
45
46 def comma_me(self,amount):
47 if not amount:
48 amount = 0.0
49 if type(amount) is float :
50 amount = str('%.2f'%amount)
51 else :
52 amount = str(amount)
53 if (amount == '0'):
54 return ' '
55 orig = amount
56 new = re.sub("^(-?\d+)(\d{3})", "\g<1>'\g<2>", amount)
57 if orig == new:
58 return new
59 else:
60 return self.comma_me(new)
61 def _ellipsis(self, string, maxlen=100, ellipsis = '...'):
62 ellipsis = ellipsis or ''
63 try:
64 return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen]
65 except Exception, e:
66 return False
67 def _strip_name(self, name, maxlen=50):
68 return self._ellipsis(name, maxlen, '...')
69
70 def _get_and_change_date_format_for_swiss (self,date_to_format):
71 date_formatted=''
72 if date_to_format:
73 date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y')
74 return date_formatted
75
76 def _explode_name(self,chaine,length):
77 # We will test if the size is less then account
78 full_string = ''
79 if (len(str(chaine)) <= length):
80 return chaine
81 #
82 else:
83 chaine = unicode(chaine,'utf8').encode('iso-8859-1')
84 rup = 0
85 for carac in chaine:
86 rup = rup + 1
87 if rup == length:
88 full_string = full_string + '\n'
89 full_string = full_string + carac
90 rup = 0
91 else:
92 full_string = full_string + carac
93
94 return full_string
95
96 def makeAscii(self,str):
97 try:
98 Stringer = str.encode("utf-8")
99 except UnicodeDecodeError:
100 try:
101 Stringer = str.encode("utf-16")
102 except UnicodeDecodeError:
103 Stringer = str
104 else:
105 return Stringer
106 else:
107 return Stringer
108 return Stringer
109 def explode_this(self,chaine,length):
110 #chaine = self.repair_string(chaine)
111 chaine = rstrip(chaine)
112 ast = list(chaine)
113 i = length
114 while i <= len(ast):
115 ast.insert(i,'\n')
116 i = i + length
117 chaine = str("".join(ast))
118 return chaine
119 def repair_string(self,chaine):
120 ast = list(chaine)
121 UnicodeAst = []
122 _previouslyfound = False
123 i = 0
124 while i < len(ast):
125 elem = ast[i]
126 try:
127 Stringer = elem.encode("utf-8")
128 except UnicodeDecodeError:
129 to_reencode = elem + ast[i+1]
130 Good_char = to_reencode.decode('utf-8')
131 UnicodeAst.append(Good_char)
132 i += i +2
133 else:
134 UnicodeAst.append(elem)
135 i += i + 1
136
137
138 return "".join(UnicodeAst)
139
140 def ReencodeAscii(self,str):
141 try:
142 Stringer = str.decode("ascii")
143 except UnicodeEncodeError:
144 return str.encode("ascii")
145 except UnicodeDecodeError:
146 return str.encode("ascii")
147
148 else:
149 return Stringer
150
151
152 # def _add_header(self, node):
153 # rml_head = tools.file_open('specific_param/report/header/corporate_rml_header_ch.rml').read()
154 # head_dom = xml.dom.minidom.parseString(rml_head)
155 # #for frame in head_dom.getElementsByTagName('frame'):
156 # # frame.parentNode.removeChild(frame)
157 # node2 = head_dom.documentElement
158 # for tag in node2.childNodes:
159 # if tag.nodeType==tag.ELEMENT_NODE:
160 # found = self._find_node(node, tag.localName)
161 # # rml_frames = found.getElementsByTagName('frame')
162 # if found:
163 # if tag.hasAttribute('position') and (tag.getAttribute('position')=='inside'):
164 # found.appendChild(tag)
165 # else:
166 # found.parentNode.replaceChild(tag, found)
167 # # for frame in rml_frames:
168 # # tag.appendChild(frame)
169 # return True
170
171
172
0173
=== added directory 'account_financial_report_web/wizard'
=== added file 'account_financial_report_web/wizard/__init__.py'
--- account_financial_report_web/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/wizard/__init__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,23 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (c) 2009 Factor Libre (http://factorlibre.com) All Rights Reserved.
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import wizard_account_balance_report
23
024
=== added file 'account_financial_report_web/wizard/wizard_account_balance_report.py'
--- account_financial_report_web/wizard/wizard_account_balance_report.py 1970-01-01 00:00:00 +0000
+++ account_financial_report_web/wizard/wizard_account_balance_report.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,244 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
7# Jordi Esteve <jesteve@zikzakmedia.com>
8# $Id$
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU Affero General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU Affero General Public License for more details.
19#
20# You should have received a copy of the GNU Affero General Public License
21# along with this program. If not, see <http://www.gnu.org/licenses/>.
22#
23##############################################################################
24
25import wizard
26import pooler
27import time
28import report
29from osv import osv, fields
30from tools.translate import _
31
32class fl_account_balance_full_report(osv.osv_memory):
33
34 _name = 'fl.account.balance.full.report'
35 _columns = {
36
37 'company_id': fields.many2one('res.company','Company',required=True),
38 'account_list':fields.many2many('account.account', 'balance_full_account_rel2', 'balance_id','account_id','Root accounts', required=True),
39 'state':fields.selection((('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')),
40 'Date/Period Filter'),
41 'fiscalyear':fields.many2one('account.fiscalyear', 'Fiscal year', required=True, help='Keep empty to use all open fiscal years to compute the balance'),
42 'periods':fields.many2many('account.period', 'balance_full_period_rel2', 'balance_id','period_id', 'Periods', help='All periods in the fiscal year if empty'),
43 'display_account':fields.selection((('bal_all','All'),('bal_solde', 'With balance'),('bal_mouvement','With movements')),'Display accounts '),
44 'display_account_level':fields.integer('Up to level', help='Display accounts up to this level (0 to show all)'),
45 'date_from':fields.date('Start date',required=True),
46 'date_to':fields.date('End date',required=True),
47 }
48 _defaults = {
49 'date_from': lambda *a: time.strftime('%Y-%m-%d'),
50 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
51 'state': lambda *a:'none',
52 'display_account_level': lambda *a: 0,
53 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c),
54 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
55 'display_account': lambda *a:'bal_all',
56 }
57
58 def onchange_company_id(self,cr,uid,ids,company_id,context=None):
59 if context is None:
60 context = {}
61 context['company_id']=company_id
62 res = {'value':{}}
63
64 if not company_id:
65 return res
66
67 cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
68 fy_id = self.pool.get('account.fiscalyear').find(cr, uid,context=context)
69 res['value'].update({'fiscalyear':fy_id})
70 res['value'].update({'account_list':[]})
71 res['value'].update({'periods':[]})
72 return res
73
74 def _get_defaults(self, cr, uid, data, context=None):
75 if context is None:
76 context = {}
77 user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
78 if user.company_id:
79 company_id = user.company_id.id
80 else:
81 company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
82 data['form']['company_id'] = company_id
83 fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
84 data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
85 data['form']['context'] = context
86 return data['form']
87
88
89 def _check_state(self, cr, uid, data, context=None):
90
91 if context is None:
92 context = {}
93 if data['form']['state'] == 'bydate':
94 self._check_date(cr, uid, data, context)
95 return data['form']
96
97 def _check_date(self, cr, uid, data, context=None):
98 if context is None:
99 context = {}
100
101 if data['form']['date_from'] > data['form']['date_to']:
102 raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
103
104 sql = """SELECT f.id, f.date_start, f.date_stop
105 FROM account_fiscalyear f
106 WHERE '%s' = f.id """%(data['form']['fiscalyear'][0])
107 cr.execute(sql)
108 res = cr.dictfetchall()
109
110 if res:
111 if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
112 raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
113 else:
114 return 'report'
115 else:
116 raise osv.except_osv(_('UserError'),'No existe periodo fiscal')
117
118 def period_span(self, cr, uid, ids, fy_id, context=None):
119 if context is None:
120 context = {}
121 ap_obj = self.pool.get('account.period')
122 fy_id = fy_id and type(fy_id) in (list,tuple) and fy_id[0] or fy_id
123 if not ids:
124 #~ No hay periodos
125 return ap_obj.search(cr, uid, [('fiscalyear_id','=',fy_id),('special','=',False)],order='date_start asc')
126
127 ap_brws = ap_obj.browse(cr, uid, ids, context=context)
128 date_start = min([period.date_start for period in ap_brws])
129 date_stop = max([period.date_stop for period in ap_brws])
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')
131
132
133 def print_report(self, cr, uid, ids, data, context=None):
134
135 if context is None:
136 context = {}
137
138 data = {}
139 data['ids'] = context.get('active_ids', [])
140 data['model'] = context.get('active_model', 'ir.ui.menu')
141 data['form'] = self.read(cr, uid, ids[0])
142 if data['form']['state'] == 'byperiod':
143 del data['form']['date_from']
144 del data['form']['date_to']
145
146 data['form']['periods'] = self.period_span(cr, uid, data['form']['periods'], data['form']['fiscalyear'])
147
148 elif data['form']['state'] == 'bydate':
149 self._check_date(cr, uid, data)
150 del data['form']['periods']
151 elif data['form']['state'] == 'none':
152 del data['form']['date_from']
153 del data['form']['date_to']
154 del data['form']['periods']
155 else:
156 self._check_date(cr, uid, data)
157 lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
158 sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
159 from account_period p
160 where p.id in %s"""%lis2
161 cr.execute(sqlmm)
162 minmax = cr.dictfetchall()
163 if minmax:
164 if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
165 raise osv.except_osv(_('Error !'),_('La interseccion entre el periodo y fecha es vacio'))
166
167 return {'type': 'ir.actions.report.xml', 'report_name': 'account.balance.full2', 'datas': data}
168
169fl_account_balance_full_report()
170
171class fl_account_general_ledger_cumulative_report(osv.osv_memory):
172
173
174 _name = 'fl.account.general.ledger.cumulative.report'
175 _columns = {
176 'account_list': fields.many2many('account.account', 'general_ledger_cumulative_rel_2', 'ledger_cumulative_id', 'account_id', 'Account'),
177 'company_id': fields.many2one('res.company', 'Company'),
178 'state': fields.selection((('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')),'Date/Period Filter'),
179 'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal year', help='Keep empty for all open fiscal year'),
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'),
181
182 'sortbydate':fields.selection((('sort_date','Date'),('sort_mvt','Movement')),'Sort by'),
183 'display_account': fields.selection((('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')), 'Display accounts'),
184
185 'landscape':fields.boolean('Landscape Mode'),
186 'initial_balance':fields.boolean('Show initial balances'),
187 'amount_currency':fields.boolean('With Currency'),
188 'date_from':fields.date('Start date',required=True),
189 'date_to':fields.date('End date',required=True),
190 'states': fields.selection((('account_selection','Account Selection'),('checktype','Check Type')), 'State'),
191
192
193
194 }
195
196 def _init_states(self, cr, uid, context=None):
197 return 'account_selection'
198
199 def step1(self, cr, uid, ids, context):
200 data={'states': 'checktype'}
201 user=self.pool.get('res.users').browse(cr, uid, uid, context=context)
202 if user.company_id:
203 company_id = user.company_id.id
204 else:
205 company_id = self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
206 data['company_id']=company_id
207 fiscalyear_obj = self.pool.get('account.fiscalyear')
208 data['fiscalyear'] = fiscalyear_obj.find(cr, uid)
209 self.write(cr, uid, ids, data)
210
211 def prints(self, cr, uid, ids, context):
212
213 if context is None:
214 context = {}
215
216 data = {}
217 data['ids'] = context.get('active_ids', [])
218 data['model'] = context.get('active_model', 'ir.ui.menu')
219 data['form'] = self.read(cr, uid, ids[0])
220 if data['form']['state'] == 'bydate':
221 sql = """SELECT f.id, f.date_start, f.date_stop
222 FROM account_fiscalyear f
223 WHERE '%s' between f.date_start and f.date_stop """ % (data['form']['date_from'])
224 cr.execute(sql)
225 res = cr.dictfetchall()
226 if res:
227 if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
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'])))
229 else:
230 raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year'))
231 if data['form']['landscape']== True:
232 return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger.cumulative.landscape2', 'datas': data}
233 else:
234 return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.ledger.cumulative2', 'datas': data}
235
236 _defaults = {
237 'date_from': lambda *a: time.strftime('%Y-01-01'),
238 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
239 'states': lambda self,cr,uid,c: self._init_states(cr, uid, context=c),
240 'state' : lambda *a:'none',
241 }
242
243fl_account_general_ledger_cumulative_report()
244# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0245
=== added directory 'report_cumulative_general_ledger_xls'
=== added file 'report_cumulative_general_ledger_xls/__init__.py'
--- report_cumulative_general_ledger_xls/__init__.py 1970-01-01 00:00:00 +0000
+++ report_cumulative_general_ledger_xls/__init__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,29 @@
1##############################################################################
2#
3# Copyright (c) 2014 Factor Libre S.L. (http://www.factorlibre.com) All Rights Reserved.
4#
5# Developer Rafael Valle
6# WARNING: This program as such is intended to be used by professional
7# programmers who take the whole responsability of assessing all potential
8# consequences resulting from its eventual inadequacies and bugs
9# End users who are looking for a ready-to-use solution with commercial
10# garantees and support are strongly adviced to contract a Free Software
11# Service Company
12#
13# This program is Free Software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation; either version 2
16# of the License, or (at your option) any later version.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, write to the Free Software
25# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26#
27##############################################################################
28
29import wizard
030
=== added file 'report_cumulative_general_ledger_xls/__openerp__.py'
--- report_cumulative_general_ledger_xls/__openerp__.py 1970-01-01 00:00:00 +0000
+++ report_cumulative_general_ledger_xls/__openerp__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,38 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2014 Factor Libre S.L (<http://www.factorlibre.com>).
6# Developer Rafael Valle
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{
23 "name" : "Report cumulative general ledger xls",
24 "description": """Allows get cumulative general ledger in xls""",
25 "version" : "1.0",
26 "author" : "Factor Libre S.L",
27 "category" : "Accounting",
28 "module": "",
29 "website": "http://www.factorlibre.com/",
30 "depends" : ["account","account_financial_report","account_financial_report_web"],
31 "init_xml" : [],
32 "update_xml" : [
33 "wizard/cumulative_general_ledger_xls_view.xml",
34 ],
35 "demo_xml" : [],
36 "active": False,
37 "installable": True
38}
039
=== added directory 'report_cumulative_general_ledger_xls/i18n'
=== added file 'report_cumulative_general_ledger_xls/i18n/es.mo'
1Binary 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 differ40Binary 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
=== added file 'report_cumulative_general_ledger_xls/i18n/es.po'
--- report_cumulative_general_ledger_xls/i18n/es.po 1970-01-01 00:00:00 +0000
+++ report_cumulative_general_ledger_xls/i18n/es.po 2014-01-29 11:51:34 +0000
@@ -0,0 +1,72 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * report_cumulative_general_ledger_xls
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1-20130627-233424\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-01-29 10:42+0000\n"
10"PO-Revision-Date: 2014-01-29 11:44+0100\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"Plural-Forms: \n"
17"X-Generator: Poedit 1.5.4\n"
18
19#. module: report_cumulative_general_ledger_xls
20#: field:fl.account.general.ledger.cumulative.report,export_file:0
21msgid "Export File"
22msgstr "Fichero generado"
23
24#. module: report_cumulative_general_ledger_xls
25#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:231
26#, python-format
27msgid "CI: "
28msgstr "CI: "
29
30#. module: report_cumulative_general_ledger_xls
31#: model:ir.model,name:report_cumulative_general_ledger_xls.model_fl_account_general_ledger_cumulative_report
32msgid "fl.account.general.ledger.cumulative.report"
33msgstr "fl.account.general.ledger.cumulative.report"
34
35#. module: report_cumulative_general_ledger_xls
36#: field:fl.account.general.ledger.cumulative.report,name:0
37msgid "Filename"
38msgstr "Nombre de Fichero"
39
40#. module: report_cumulative_general_ledger_xls
41#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:233
42#, python-format
43msgid "OR: "
44msgstr "OR: "
45
46#. module: report_cumulative_general_ledger_xls
47#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:234
48#, python-format
49msgid "SR: "
50msgstr "SR: "
51
52#. module: report_cumulative_general_ledger_xls
53#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:232
54#, python-format
55msgid "SI: "
56msgstr "SI: "
57
58#. module: report_cumulative_general_ledger_xls
59#: code:addons/report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py:293
60#, python-format
61msgid "Initial balance"
62msgstr "Balance Inicial"
63
64#. module: report_cumulative_general_ledger_xls
65#: view:fl.account.general.ledger.cumulative.report:0
66msgid "XLS"
67msgstr "XLS"
68
69#. module: report_cumulative_general_ledger_xls
70#: view:fl.account.general.ledger.cumulative.report:0
71msgid "Export XLS"
72msgstr "Generar XLS"
073
=== added directory 'report_cumulative_general_ledger_xls/wizard'
=== added file 'report_cumulative_general_ledger_xls/wizard/__init__.py'
--- report_cumulative_general_ledger_xls/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ report_cumulative_general_ledger_xls/wizard/__init__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,27 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2014 Rafael Valle (Factor Libre S.L) (<http://factorlibre.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import cumulative_general_ledger
23
24
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
26
27
028
=== added file 'report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py'
--- report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py 1970-01-01 00:00:00 +0000
+++ report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,434 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2013 Factor Libre.
6# Developer Rafael Valle
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import time, dateutil, dateutil.tz
24from datetime import date, datetime
25
26import cStringIO
27import base64
28from xlwt import *
29import pooler
30from osv import osv, fields
31from tools.translate import _
32import logging
33_logger = logging.getLogger(__name__)
34
35class fl_account_general_ledger_cumulative_report(osv.osv_memory):
36 _inherit = "fl.account.general.ledger.cumulative.report"
37
38
39
40 _columns = {
41 'name': fields.char('Filename', size=64, readonly=True),
42 'export_file': fields.binary('Export File', readonly=True),
43 }
44
45
46
47
48
49
50 def get_fiscalyear(self, cr, uid, form):
51 res=[]
52 if form.has_key('fiscalyear'):
53 fisc_id = form['fiscalyear'][0]
54 if not (fisc_id):
55 return ''
56 cr.execute("SELECT name FROM account_fiscalyear WHERE id = %s" , (int(fisc_id),))
57 res=cr.fetchone()
58 return res and res[0] or ''
59
60
61 def get_periods(self, cr, uid, form):
62 result=''
63 if form.has_key('periods') and form['periods']:
64 period_ids = ",".join([str(x) for x in form['periods'] if x])
65 self.cr.execute("SELECT name FROM account_period WHERE id in (%s)" % (period_ids))
66 res = self.cr.fetchall()
67 len_res = len(res)
68 for r in res:
69 if (r == res[len_res-1]):
70 result+=r[0]+". "
71 else:
72 result+=r[0]+", "
73 elif form.has_key('date_from') and form.has_key('date_to'):
74 result = form['date_from'] + ' - ' + form['date_to'] + ' '
75 else:
76 fy_obj = self.pool.get('account.fiscalyear').browse(cr,uid,form['fiscalyear'][0])
77 res = fy_obj.period_ids
78 len_res = len(res)
79 for r in res:
80 if r == res[len_res-1]:
81 result+=r.name+". "
82 else:
83 result+=r.name+", "
84
85 return str(result and result[:-1]) or ''
86
87
88
89 def _sum_balance_account(self, cr, uid, account, form, ctxfy):
90 # Balance from init fiscal year to last date given by the user
91 accounts = self.pool.get('account.account').read(cr, uid, [account.id], ['balance'], ctxfy)
92 sum_balance = accounts[0]['balance']
93 return sum_balance
94
95
96 def _sum_debit_account(self, cr, uid, account, form, query):
97 cr.execute("SELECT sum(debit) "\
98 "FROM account_move_line l "\
99 "WHERE l.account_id = %s AND %s " % (account.id, query))
100 sum_debit = cr.fetchone()[0] or 0.0
101 return sum_debit
102
103
104 def _sum_credit_account(self, cr, uid, account, form, query):
105 cr.execute("SELECT sum(credit) "\
106 "FROM account_move_line l "\
107 "WHERE l.account_id = %s AND %s " % (account.id, query))
108 sum_credit = cr.fetchone()[0] or 0.0
109 return sum_credit
110
111
112 def _calc_contrepartie(self, cr, uid, ids, context={}):
113 result = {}
114 #for id in ids:
115 # result.setdefault(id, False)
116 for account_line in self.pool.get('account.move.line').browse(cr, uid, ids, context):
117 # For avoid long text in the field we will limit it to 5 lines
118 #
119 result[account_line.id] = ' '
120 num_id_move = str(account_line.move_id.id)
121 num_id_line = str(account_line.id)
122 account_id = str(account_line.account_id.id)
123 # search the basic account
124 # We have the account ID we will search all account move line from now until this time
125 # We are in the case of we are on the top of the account move Line
126 cr.execute("SELECT distinct(ac.code) as code_rest,ac.name as name_rest "\
127 "FROM account_account AS ac, account_move_line mv "\
128 "WHERE ac.id = mv.account_id and mv.move_id = " + num_id_move + " and mv.account_id <> " + account_id )
129 res_mv = cr.dictfetchall()
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
131 if (len(res_mv) >=1):
132 concat = ''
133 rup_id = 0
134 for move_rest in res_mv:
135 concat = concat + move_rest['code_rest'] + '|'
136 result[account_line.id] = concat
137 if rup_id >5:
138 # we need to stop the computing and to escape but before we will add "..."
139 result[account_line.id] = concat + '...'
140 break
141 rup_id+=1
142 return result
143
144 def get_children_accounts(self, cr, uid, account, form, query, ctx, context=None):
145 balance_accounts = {}
146 move_line_obj = self.pool.get('account.move.line')
147 account_obj = self.pool.get('account.account')
148 invoice_obj = self.pool.get('account.invoice')
149 child_ids = account_obj.search(cr, uid, [('parent_id', 'child_of', form['account_list'])])
150 res = []
151 ctx = ctx.copy()
152 if account and account.child_consol_ids: # add ids of consolidated childs also of selected account
153 ctx['consolidate_childs'] = True
154 ctx['account_id'] = account.id
155 ids_acc = account_obj.search(cr, uid,[('parent_id', 'child_of', [account.id])], context=ctx)
156 for child_id in ids_acc:
157 child_account = account_obj.browse(cr, uid, child_id)
158 balance_account = self._sum_balance_account( cr, uid, child_account, form, {})
159 balance_accounts[child_account.id] = balance_account
160 if form['display_account'] == 'bal_mouvement':
161 if child_account.type != 'view' \
162 and len(move_line_obj.search(cr, uid,
163 [('account_id','=',child_account.id)],
164 context=ctx)) <> 0 :
165 res.append(child_account)
166 elif form['display_account'] == 'bal_solde':
167 if child_account.type != 'view' \
168 and len(move_line_obj.search(cr, uid,
169 [('account_id','=',child_account.id)],
170 context=ctx)) <> 0 :
171 if balance_account <> 0.0:
172 res.append(child_account)
173 else:
174 if child_account.type != 'view' \
175 and len(move_line_obj.search(cr, uid,
176 [('account_id','>=',child_account.id)],
177 context=ctx)) <> 0 :
178 res.append(child_account)
179 ##
180 if not len(res):
181 return [account]
182 else:
183 ## We will now compute initial balance
184 for move in res:
185 sql_balance_init = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit "\
186 "FROM account_move_line l "\
187 "WHERE l.account_id = " + str(move.id) + " AND %s" % (query)
188 cr.execute(sql_balance_init)
189 resultat = cr.dictfetchall()
190 if resultat[0] :
191 if resultat[0]['sum_debit'] == None:
192 sum_debit = 0
193 else:
194 sum_debit = resultat[0]['sum_debit']
195 if resultat[0]['sum_credit'] == None:
196 sum_credit = 0
197 else:
198 sum_credit = resultat[0]['sum_credit']
199
200 move.init_credit = sum_credit
201 move.init_debit = sum_debit
202 else:
203 move.init_credit = 0
204 move.init_debit = 0
205 return res
206
207
208
209 def lines(self, cr, uid, account, form, query, ctxfy):
210 tot_currency = 0.0
211 date_min = period_min = False
212 date_min = form['date_from']
213
214 #dates
215 if not period_min:
216 min_date = date_min
217 elif not date_min:
218 min_date = period_min
219 else:
220 # If period and date are given, the maximum of the min dates is choosed
221 if period_min < date_min:
222 min_date = date_min
223 else:
224 min_date = period_min
225
226
227
228
229 print query
230 inv_types = {
231 'out_invoice': _('CI: '),
232 'in_invoice': _('SI: '),
233 'out_refund': _('OR: '),
234 'in_refund': _('SR: '),
235 }
236
237 if form['sortbydate'] == 'sort_date':
238 sorttag = 'l.date'
239 else:
240 sorttag = 'j.code'
241 sql = """
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
243 FROM account_move_line as l
244 LEFT JOIN res_currency c on (l.currency_id=c.id)
245 JOIN account_journal j on (l.journal_id=j.id)
246 AND account_id = %%s
247 AND %s
248 ORDER by %s""" % (query, sorttag)
249 cr.execute(sql % account.id)
250
251 res = cr.dictfetchall()
252 move_line_obj = self.pool.get('account.move.line')
253 account_obj = self.pool.get('account.account')
254 invoice_obj = self.pool.get('account.invoice')
255
256 # Balance from init fiscal year to last date given by the user
257 accounts = account_obj.read(cr, uid, [account.id], ['balance'], ctxfy)
258 sum = accounts[0]['balance']
259
260 for l in reversed(res):
261 line = move_line_obj.browse(cr, uid, l['id'])
262 l['move'] = line.move_id.name_split
263 cr.execute('Select id from account_invoice where move_id =%s'%(line.move_id.id))
264 tmpres = cr.dictfetchall()
265 if len(tmpres) > 0 :
266 inv = invoice_obj.browse(cr, uid, tmpres[0]['id'])
267 l['ref'] = inv_types[inv.type] + ': '+str(inv.number)
268 if line.partner_id :
269 l['partner'] = line.partner_id.name
270 else :
271 l['partner'] = ''
272 l['line_corresp'] = self._calc_contrepartie(cr,uid,[l['id']])[l['id']]
273
274 # Cumulative balance update
275 l['progress'] = sum
276 sum = sum - l['debit'] + l ['credit']
277
278 # Modification of currency amount
279 if (l['credit'] > 0):
280 if l['amount_currency'] != None:
281 l['amount_currency'] = abs(l['amount_currency']) * -1
282 if l['amount_currency'] != None:
283 tot_currency = tot_currency + l['amount_currency']
284
285 decimal_precision_obj = self.pool.get('decimal.precision')
286 ids = decimal_precision_obj.search(cr, uid, [('name', '=', 'Account')])
287 digits = decimal_precision_obj.browse(cr, uid, ids)[0].digits
288
289 #if abs(sum) > 10**-int(config['price_accuracy']) and form['initial_balance']:
290 if round(sum,digits) <> 0.0 and form['initial_balance']:
291 res.insert(0, {
292 'date': self.min_date,
293 'name': _('Initial balance'),
294 'progress': sum,
295 'partner': '',
296 'move': '',
297 'ref': '',
298 'debit': '',
299 'credit': '',
300 'amount_currency': '',
301 'currency_code': '',
302 'code': '',
303 'line_corresp': '',
304 })
305
306 return res
307
308
309
310
311 def get_report_file_xls(self, cr, uid, ids, context=None):
312
313 if context is None:
314 context = {}
315
316 data=self.prints(cr, uid, ids, context)
317 print data
318
319
320 #vals context
321 ctx2 = data['datas']['form'].get('used_context',{}).copy()
322 tot_currency = 0.0
323 sortby = data['datas']['form'].get('sortby', 'sort_date')
324
325 ctx = context.copy()
326 if 'fiscalyear' in data['datas']['form'] and data['datas']['form']['fiscalyear']:
327 ctx['fiscalyear'] = data['datas']['form']['fiscalyear'][0]
328 if data['datas']['form']['state'] in ['byperiod', 'all']:
329 ctx['periods'] = data['datas']['form']['periods']
330 if data['datas']['form']['state'] in ['bydate', 'all']:
331 ctx['date_from'] = data['datas']['form']['date_from']
332 ctx['date_to'] = data['datas']['form']['date_to']
333 if 'periods' not in ctx:
334 ctx['periods'] = []
335 ctx = ctx
336
337 ctxfy = ctx.copy()
338 ctxfy['periods'] = ctx['periods'][:]
339
340 #-----------------------------------------
341
342 query = self.pool.get('account.move.line')._query_get(cr, uid, context=ctx)
343
344
345 user = self.pool.get('res.users').browse(cr, uid, uid, context = context)
346
347 user_tz = dateutil.tz.gettz(user.context_tz)
348 utc_tz = dateutil.tz.tzutc()
349
350
351 excel_temp = cStringIO.StringIO()
352 w = Workbook(encoding='utf-8', style_compression=2)
353 ws = w.add_sheet('Hoja 1')
354
355 #styles
356 style_headers1 = XFStyle()
357 # font
358 font = Font()
359 font.bold = True
360 style_headers1.font = font
361 # borders
362 borders = Borders()
363 borders.bottom = Borders.DASHED
364 style_headers1.borders = borders
365
366 style_bold = XFStyle()
367 # font
368 font = Font()
369 font.bold = True
370 style_bold.font = font
371
372
373 # Header definition
374 ws.write_merge(0, 0, 0, 11,'LIBRO MAYOR ACUMULADO',style=style_headers1)
375
376
377 #Main Headers
378 ws.write(1,0,'Año Fiscal', style=style_headers1)
379 ws.write(2,0,'Periodos', style=style_headers1)
380
381
382
383 ws.write(1,1,self.get_fiscalyear(cr,uid,data['datas']['form']))
384 ws.write(2,1,self.get_periods(cr,uid,data['datas']['form']))
385
386
387 #Table headers
388
389 ws.write(6,0,'Fecha', style=style_headers1)
390 ws.write(6,1,'Asiento', style=style_headers1)
391 ws.write(6,2,'Empresa', style=style_headers1)
392 ws.write(6,3,'Ref', style=style_headers1)
393 ws.write(6,4,'Debe', style=style_headers1)
394 ws.write(6,5,'Haber', style=style_headers1)
395 ws.write(6,6,'Balance', style=style_headers1)
396
397
398 row=7
399 #Children accounts
400
401 for account_id in data['datas']['form']['account_list']:
402 acc_obj=self.pool.get('account.account').browse(cr,uid,account_id)
403 for a in self.get_children_accounts(cr, uid, acc_obj, data['datas']['form'], query, ctx, context):
404 ws.write(row,0,a.code+' '+a.name, style=style_bold)
405 ws.write(row,4,self._sum_debit_account(cr, uid, a, data['datas']['form'], query), style=style_bold)
406 ws.write(row,5,self._sum_credit_account(cr, uid, a, data['datas']['form'], query), style=style_bold)
407 ws.write(row,6,self._sum_balance_account( cr, uid, a, data['datas']['form'], ctxfy), style=style_bold)
408 row=row+1
409
410 #lines children
411 for a_line in self.lines(cr, uid, a, data['datas']['form'], query, ctxfy):
412
413 #format date
414 ldated=datetime.strptime(a_line['date'], '%Y-%m-%d')
415
416 ws.write(row,0,ldated.strftime('%d/%m/%Y'))
417 ws.write(row,1,a_line['move'])
418 ws.write(row,2,a_line['partner'])
419 ws.write(row,3,a_line['ref'])
420 ws.write(row,4,a_line['debit'])
421 ws.write(row,5,a_line['credit'])
422 ws.write(row,6,a_line['progress'])
423 row=row+1
424
425 w.save(excel_temp)
426 out=base64.encodestring(excel_temp.getvalue())
427 excel_temp.close()
428 file_time = datetime.now(user_tz).strftime('%Y-%m-%d_%H%M')
429
430
431 return self.write(cr, uid, ids, { 'export_file': out, 'name': 'Libro_Mayor_Acumulado_%s.xls' % (file_time)})
432
433fl_account_general_ledger_cumulative_report()
434
0435
=== added file 'report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger_xls_view.xml'
--- report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger_xls_view.xml 1970-01-01 00:00:00 +0000
+++ report_cumulative_general_ledger_xls/wizard/cumulative_general_ledger_xls_view.xml 2014-01-29 11:51:34 +0000
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="account_general_ledger_cumulative_report_view_xls" model="ir.ui.view">
6 <field name="name">account general ledger cumulative report XLS</field>
7 <field name="model">fl.account.general.ledger.cumulative.report</field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="account_financial_report_web.account_general_ledger_cumulative_report_form2" />
10 <field name="arch" type="xml">
11 <data>
12
13 <field name="initial_balance" position="after">
14 <newline/>
15 <separator string="XLS" colspan="4"/>
16 <field name="name" invisible="1"/>
17 <field name="export_file" filename="name" />
18 <button icon="gtk-print" name="get_report_file_xls" string="Export XLS" type="object" colspan="2" default_focus="1"/>
19
20 </field>
21 </data>
22 </field>
23 </record>
24
25 </data>
26</openerp>
027
=== added directory 'report_general_ledger_xls'
=== added file 'report_general_ledger_xls/__init__.py'
--- report_general_ledger_xls/__init__.py 1970-01-01 00:00:00 +0000
+++ report_general_ledger_xls/__init__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,29 @@
1##############################################################################
2#
3# Copyright (c) 2014 Factor Libre S.L. (http://www.factorlibre.com) All Rights Reserved.
4#
5# Developer Rafael Valle
6# WARNING: This program as such is intended to be used by professional
7# programmers who take the whole responsability of assessing all potential
8# consequences resulting from its eventual inadequacies and bugs
9# End users who are looking for a ready-to-use solution with commercial
10# garantees and support are strongly adviced to contract a Free Software
11# Service Company
12#
13# This program is Free Software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation; either version 2
16# of the License, or (at your option) any later version.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, write to the Free Software
25# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26#
27##############################################################################
28
29import wizard
030
=== added file 'report_general_ledger_xls/__openerp__.py'
--- report_general_ledger_xls/__openerp__.py 1970-01-01 00:00:00 +0000
+++ report_general_ledger_xls/__openerp__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,39 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2014 Factor Libre S.L (<http://www.factorlibre.com>).
6# Developer Rafael Valle
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23{
24 "name" : "report general ledger xls",
25 "description": """Allows get general ledger in xls""",
26 "version" : "1.0",
27 "author" : "Factor Libre S.L",
28 "category" : "Generic Modules",
29 "module": "",
30 "website": "http://www.factorlibre.com/",
31 "depends" : ["account"],
32 "init_xml" : [],
33 "update_xml" : [
34 "wizard/account_report_ledger_xls_view.xml",
35 ],
36 "demo_xml" : [],
37 "active": False,
38 "installable": True
39}
040
=== added directory 'report_general_ledger_xls/i18n'
=== added file 'report_general_ledger_xls/i18n/es.mo'
1Binary 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 differ41Binary 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
=== added file 'report_general_ledger_xls/i18n/es.po'
--- report_general_ledger_xls/i18n/es.po 1970-01-01 00:00:00 +0000
+++ report_general_ledger_xls/i18n/es.po 2014-01-29 11:51:34 +0000
@@ -0,0 +1,63 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * fl_report_general_ledger_xls
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1-20130627-233424\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-01-17 10:06+0000\n"
10"PO-Revision-Date: 2014-01-17 11:07+0100\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"Plural-Forms: \n"
17"X-Generator: Poedit 1.5.4\n"
18
19#. module: fl_report_general_ledger_xls
20#: constraint:account.report.general.ledger:0
21msgid ""
22"The fiscalyear, periods or chart of account chosen have to belong to the "
23"same company."
24msgstr ""
25"El ejercicio fiscal, periodos y árbol de cuentas escogido deben pertenecer a "
26"la misma compañía."
27
28#. module: fl_report_general_ledger_xls
29#: field:account.report.general.ledger,export_file:0
30msgid "Export File"
31msgstr "Fichero"
32
33#. module: fl_report_general_ledger_xls
34#: code:addons/fl_report_general_ledger_xls/wizard/account_report_general_ledger.py:69
35#, python-format
36msgid "All Posted Entries"
37msgstr "All Posted Entries"
38
39#. module: fl_report_general_ledger_xls
40#: field:account.report.general.ledger,name:0
41msgid "Filename"
42msgstr "Nombre de fichero"
43
44#. module: fl_report_general_ledger_xls
45#: model:ir.model,name:fl_report_general_ledger_xls.model_account_report_general_ledger
46msgid "General Ledger Report"
47msgstr "Informe del libro mayor"
48
49#. module: fl_report_general_ledger_xls
50#: view:account.report.general.ledger:0
51msgid "XLS"
52msgstr "XLS"
53
54#. module: fl_report_general_ledger_xls
55#: code:addons/fl_report_general_ledger_xls/wizard/account_report_general_ledger.py:68
56#, python-format
57msgid "All Entries"
58msgstr "All Entries"
59
60#. module: fl_report_general_ledger_xls
61#: view:account.report.general.ledger:0
62msgid "Export XLS"
63msgstr "Generar XLS"
064
=== added directory 'report_general_ledger_xls/wizard'
=== added file 'report_general_ledger_xls/wizard/__init__.py'
--- report_general_ledger_xls/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ report_general_ledger_xls/wizard/__init__.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,27 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2014 Rafael Valle (Factor Libre S.L) (<http://factorlibre.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import account_report_general_ledger
23
24
25# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
26
27
028
=== added file 'report_general_ledger_xls/wizard/account_report_general_ledger.py'
--- report_general_ledger_xls/wizard/account_report_general_ledger.py 1970-01-01 00:00:00 +0000
+++ report_general_ledger_xls/wizard/account_report_general_ledger.py 2014-01-29 11:51:34 +0000
@@ -0,0 +1,407 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2013 Factor Libre.
6# Developer Rafael Valle
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import time, dateutil, dateutil.tz
24from datetime import date, datetime
25
26import cStringIO
27import base64
28from xlwt import *
29import pooler
30from osv import osv, fields
31from tools.translate import _
32import logging
33_logger = logging.getLogger(__name__)
34
35class account_report_general_ledger(osv.osv_memory):
36 _inherit = "account.report.general.ledger"
37
38
39
40 _columns = {
41 'name': fields.char('Filename', size=64, readonly=True),
42 'export_file': fields.binary('Export File', readonly=True),
43 }
44
45
46
47 def _get_account(self, cr, uid, data):
48 if data.get('form', False) and data['form'].get('chart_account_id', False):
49 return pooler.get_pool(cr.dbname).get('account.account').browse(cr, uid, data['form']['chart_account_id']).name
50 return ''
51
52
53 def _get_fiscalyear(self, cr, uid, data):
54 if data.get('form', False) and data['form'].get('fiscalyear_id', False):
55 return pooler.get_pool(cr.dbname).get('account.fiscalyear').browse(cr, uid, data['form']['fiscalyear_id']).name
56 return ''
57
58 def _get_journal(self, cr, uid, data):
59 codes = []
60 if data.get('form', False) and data['form'].get('journal_ids', False):
61 cr.execute('select code from account_journal where id IN %s',(tuple(data['form']['journal_ids']),))
62 codes = ','.join([x for x, in cr.fetchall()])
63 return codes
64
65 def _get_target_move(self, cr, uid, data):
66 if data.get('form', False) and data['form'].get('target_move', False):
67 if data['form']['target_move'] == 'all':
68 return _('All Entries')
69 return _('All Posted Entries')
70 return ''
71
72
73
74
75 def _sum_balance_account(self, cr, uid, account, query, target_move, init_balance):
76 if account.type == 'view':
77 return account.balance
78 move_state = ['draft','posted']
79 if target_move == 'posted':
80 move_state = ['posted','']
81 cr.execute('SELECT (sum(debit) - sum(credit)) as tot_balance \
82 FROM account_move_line l \
83 JOIN account_move am ON (am.id = l.move_id) \
84 WHERE (l.account_id = %s) \
85 AND (am.state IN %s) \
86 AND '+ query +' '
87 ,(account.id, tuple(move_state)))
88 sum_balance = cr.fetchone()[0] or 0.0
89 if init_balance:
90 cr.execute('SELECT (sum(debit) - sum(credit)) as tot_balance \
91 FROM account_move_line l \
92 JOIN account_move am ON (am.id = l.move_id) \
93 WHERE (l.account_id = %s) \
94 AND (am.state IN %s) \
95 AND '+ self.init_query +' '
96 ,(account.id, tuple(move_state)))
97 # Add initial balance to the result
98 sum_balance += cr.fetchone()[0] or 0.0
99 return sum_balance
100
101
102 def _sum_credit_account(self, cr, uid, account, target_move, init_balance, query, init_query):
103 if account.type == 'view':
104 return account.credit
105 move_state = ['draft','posted']
106 if target_move == 'posted':
107 move_state = ['posted','']
108 cr.execute('SELECT sum(credit) \
109 FROM account_move_line l \
110 JOIN account_move am ON (am.id = l.move_id) \
111 WHERE (l.account_id = %s) \
112 AND (am.state IN %s) \
113 AND '+ query +' '
114 ,(account.id, tuple(move_state)))
115 sum_credit = cr.fetchone()[0] or 0.0
116 if init_balance:
117 cr.execute('SELECT sum(credit) \
118 FROM account_move_line l \
119 JOIN account_move am ON (am.id = l.move_id) \
120 WHERE (l.account_id = %s) \
121 AND (am.state IN %s) \
122 AND '+ init_query +' '
123 ,(account.id, tuple(move_state)))
124 # Add initial balance to the result
125 sum_credit += cr.fetchone()[0] or 0.0
126 return sum_credit
127
128 def _sum_debit_account(self, cr, uid, account, target_move, init_balance, query, init_query):
129 if account.type == 'view':
130 return account.debit
131 move_state = ['draft','posted']
132 if target_move == 'posted':
133 move_state = ['posted','']
134 cr.execute('SELECT sum(debit) \
135 FROM account_move_line l \
136 JOIN account_move am ON (am.id = l.move_id) \
137 WHERE (l.account_id = %s) \
138 AND (am.state IN %s) \
139 AND '+ query +' '
140 ,(account.id, tuple(move_state)))
141 sum_debit = cr.fetchone()[0] or 0.0
142 if init_balance:
143 cr.execute('SELECT sum(debit) \
144 FROM account_move_line l \
145 JOIN account_move am ON (am.id = l.move_id) \
146 WHERE (l.account_id = %s) \
147 AND (am.state IN %s) \
148 AND '+ init_query +' '
149 ,(account.id, tuple(move_state)))
150 # Add initial balance to the result
151 sum_debit += cr.fetchone()[0] or 0.0
152 return sum_debit
153
154 def get_children_accounts(self, cr, uid, account, data, context):
155 res = []
156
157 ctx2 = data['form'].get('used_context',{}).copy()
158 query = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=data['form'].get('used_context',{}))
159 sold_accounts = {}
160 display_account = data['form']['display_account']
161 target_move = data['form'].get('target_move', 'all')
162 init_balance = data['form'].get('initial_balance', True)
163 if init_balance:
164 ctx2.update({'initial_bal': True})
165 init_query = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=ctx2)
166
167 account=self.pool.get('account.account').browse(cr,uid,account)
168 currency_obj = self.pool.get('res.currency')
169 ids_acc = self.pool.get('account.account')._get_children_and_consol(cr, uid, account.id)
170 currency = account.currency_id and account.currency_id or account.company_id.currency_id
171 for child_account in self.pool.get('account.account').browse(cr, uid, ids_acc, context=context):
172 sql = """
173 SELECT count(id)
174 FROM account_move_line AS l
175 WHERE %s AND l.account_id = %%s
176 """ % (query)
177 cr.execute(sql, (child_account.id,))
178 num_entry = cr.fetchone()[0] or 0
179 sold_account = self._sum_balance_account(cr, uid, child_account, query, target_move, init_balance)
180 sold_accounts[child_account.id] = sold_account
181 if display_account == 'movement':
182 if child_account.type != 'view' and num_entry <> 0:
183 res.append(child_account)
184 elif display_account == 'not_zero':
185 if child_account.type != 'view' and num_entry <> 0:
186 if not currency_obj.is_zero(cr, uid, currency, sold_account):
187 res.append(child_account)
188 else:
189 res.append(child_account)
190 if not res:
191 return [account]
192 return res
193
194
195
196 def _get_period(self, cr, uid, move):
197 if move:
198 acc_move_ids=self.pool.get('account.move').search(cr, uid, [('name','=',move)])
199 if acc_move_ids:
200 acc_move_obj=self.pool.get('account.move').browse(cr, uid, acc_move_ids[0])
201 if acc_move_obj.period_id:
202 return acc_move_obj.period_id.name
203 return ''
204
205
206 def lines(self, cr, uid, account, sortby, tot_currency, target_move, init_balance, query, init_query):
207 """ Return all the account_move_line of account with their account code counterparts """
208 move_state = ['draft','posted']
209 if target_move == 'posted':
210 move_state = ['posted', '']
211 # First compute all counterpart strings for every move_id where this account appear.
212 # Currently, the counterpart info is used only in landscape mode
213 sql = """
214 SELECT m1.move_id,
215 array_to_string(ARRAY(SELECT DISTINCT a.code
216 FROM account_move_line m2
217 LEFT JOIN account_account a ON (m2.account_id=a.id)
218 WHERE m2.move_id = m1.move_id
219 AND m2.account_id<>%%s), ', ') AS counterpart
220 FROM (SELECT move_id
221 FROM account_move_line l
222 LEFT JOIN account_move am ON (am.id = l.move_id)
223 WHERE am.state IN %s and %s AND l.account_id = %%s GROUP BY move_id) m1
224 """% (tuple(move_state), query)
225 cr.execute(sql, (account.id, account.id))
226 counterpart_res = cr.dictfetchall()
227 counterpart_accounts = {}
228 for i in counterpart_res:
229 counterpart_accounts[i['move_id']] = i['counterpart']
230 del counterpart_res
231
232 # Then select all account_move_line of this account
233 if sortby == 'sort_journal_partner':
234 sql_sort='j.code, p.name, l.move_id'
235 else:
236 sql_sort='l.date, l.move_id'
237 sql = """
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,
239 m.name AS move_name, m.id AS mmove_id,per.code as period_code,
240 c.symbol AS currency_code,
241 i.id AS invoice_id, i.type AS invoice_type, i.number AS invoice_number,
242 p.name AS partner_name
243 FROM account_move_line l
244 JOIN account_move m on (l.move_id=m.id)
245 LEFT JOIN res_currency c on (l.currency_id=c.id)
246 LEFT JOIN res_partner p on (l.partner_id=p.id)
247 LEFT JOIN account_invoice i on (m.id =i.move_id)
248 LEFT JOIN account_period per on (per.id=l.period_id)
249 JOIN account_journal j on (l.journal_id=j.id)
250 WHERE %s AND m.state IN %s AND l.account_id = %%s ORDER by %s
251 """ %(query, tuple(move_state), sql_sort)
252 cr.execute(sql, (account.id,))
253 res_lines = cr.dictfetchall()
254 res_init = []
255 if res_lines and init_balance:
256 #FIXME: replace the label of lname with a string translatable
257 sql = """
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,
259 '' AS move_name, '' AS mmove_id, '' AS period_code,
260 '' AS currency_code,
261 NULL AS currency_id,
262 '' AS invoice_id, '' AS invoice_type, '' AS invoice_number,
263 '' AS partner_name
264 FROM account_move_line l
265 LEFT JOIN account_move m on (l.move_id=m.id)
266 LEFT JOIN res_currency c on (l.currency_id=c.id)
267 LEFT JOIN res_partner p on (l.partner_id=p.id)
268 LEFT JOIN account_invoice i on (m.id =i.move_id)
269 JOIN account_journal j on (l.journal_id=j.id)
270 WHERE %s AND m.state IN %s AND l.account_id = %%s
271 """ %(init_query, tuple(move_state))
272 cr.execute(sql, (account.id,))
273 res_init = cr.dictfetchall()
274 res = res_init + res_lines
275 account_sum = 0.0
276 for l in res:
277 l['move'] = l['move_name'] != '/' and l['move_name'] or ('*'+str(l['mmove_id']))
278 l['partner'] = l['partner_name'] or ''
279 account_sum += l['debit'] - l['credit']
280 l['progress'] = account_sum
281 l['line_corresp'] = l['mmove_id'] == '' and ' ' or counterpart_accounts[l['mmove_id']].replace(', ',',')
282 # Modification of amount Currency
283 if l['credit'] > 0:
284 if l['amount_currency'] != None:
285 l['amount_currency'] = abs(l['amount_currency']) * -1
286 if l['amount_currency'] != None:
287 tot_currency = tot_currency + l['amount_currency']
288 return res
289
290 def get_report_file_xls(self, cr, uid, ids, context=None):
291
292 if context is None:
293 context = {}
294
295 data=self.check_report(cr, uid, ids, context)
296
297 #vals context
298 ctx2 = data['datas']['form'].get('used_context',{}).copy()
299 tot_currency = 0.0
300 sortby = data['datas']['form'].get('sortby', 'sort_date')
301 query = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=data['datas']['form'].get('used_context',{}))
302 sold_accounts = {}
303 display_account = data['datas']['form']['display_account']
304 target_move = data['datas']['form'].get('target_move', 'all')
305 init_balance = data['datas']['form'].get('initial_balance', True)
306 if init_balance:
307 ctx2.update({'initial_bal': True})
308 init_query = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=ctx2)
309
310 user = self.pool.get('res.users').browse(cr, uid, uid, context = context)
311
312 user_tz = dateutil.tz.gettz(user.context_tz)
313 utc_tz = dateutil.tz.tzutc()
314
315
316 excel_temp = cStringIO.StringIO()
317 w = Workbook(encoding='utf-8', style_compression=2)
318 ws = w.add_sheet('Hoja 1')
319
320 #styles
321 style_headers1 = XFStyle()
322 # font
323 font = Font()
324 font.bold = True
325 style_headers1.font = font
326 # borders
327 borders = Borders()
328 borders.bottom = Borders.DASHED
329 style_headers1.borders = borders
330
331 style_bold = XFStyle()
332 # font
333 font = Font()
334 font.bold = True
335 style_bold.font = font
336
337
338 # Header definition
339 ws.write_merge(0, 0, 0, 11,'LIBRO MAYOR',style=style_headers1)
340
341
342 #Main Headers
343 ws.write(1,0,'Plan Contable', style=style_headers1)
344 ws.write(2,0,'Ejercicio Fiscal', style=style_headers1)
345 ws.write(3,0,'Diarios', style=style_headers1)
346 ws.write(4,0,'Movimientos destino', style=style_headers1)
347
348 ws.write(1,1,self._get_account(cr,uid,data['datas']))
349 ws.write(2,1,self._get_fiscalyear(cr,uid,data['datas']))
350 ws.write(3,1,self._get_journal(cr,uid,data['datas']))
351 ws.write(4,1,self._get_target_move(cr,uid,data['datas']))
352
353
354 #Table headers
355
356 ws.write(6,0,'Fecha', style=style_headers1)
357 ws.write(6,1,'Periodo', style=style_headers1)
358 ws.write(6,2,'Libro', style=style_headers1)
359 ws.write(6,3,'Empresa', style=style_headers1)
360 ws.write(6,4,'Ref', style=style_headers1)
361 ws.write(6,5,'Asiento', style=style_headers1)
362 ws.write(6,6,'Etiqueta Asiento', style=style_headers1)
363 ws.write(6,7,'Contrapartida', style=style_headers1)
364 ws.write(6,8,'Debe', style=style_headers1)
365 ws.write(6,9,'Haber', style=style_headers1)
366 ws.write(6,10,'Saldo Pendiente', style=style_headers1)
367 ws.write(6,11,'Divisa', style=style_headers1)
368
369 row=7
370 #Children accounts
371 for a in self.get_children_accounts(cr, uid, data['datas']['form']['chart_account_id'],data['datas'], context):
372 ws.write(row,0,a.code+' '+a.name, style=style_bold)
373 ws.write(row,8,self._sum_debit_account(cr, uid, a, target_move, init_balance, query, init_query), style=style_bold)
374 ws.write(row,9,self._sum_credit_account(cr, uid, a, target_move, init_balance, query, init_query), style=style_bold)
375 #ws.write(row,10,self._sum_balance_account(cr, uid, a, query, target_move, init_balance))
376 row=row+1
377
378 #lines children
379 for a_line in self.lines(cr, uid, a, sortby, tot_currency, target_move, init_balance, query, init_query):
380
381 #format date
382 ldated=datetime.strptime(a_line['ldate'], '%Y-%m-%d')
383
384 ws.write(row,0,ldated.strftime('%d/%m/%Y'))
385 ws.write(row,1,self._get_period(cr, uid, a_line['move']))
386 ws.write(row,2,a_line['lcode'])
387 ws.write(row,3,a_line['partner_name'])
388 ws.write(row,4,a_line['lref'])
389 ws.write(row,5,a_line['move'])
390 ws.write(row,6,a_line['lname'])
391 ws.write(row,7,a_line['line_corresp'])
392 ws.write(row,8,a_line['debit'])
393 ws.write(row,9,a_line['credit'])
394 ws.write(row,10,a_line['progress'])
395 ws.write(row,11,a_line['currency_code'] or '')
396 row=row+1
397
398 w.save(excel_temp)
399 out=base64.encodestring(excel_temp.getvalue())
400 excel_temp.close()
401 file_time = datetime.now(user_tz).strftime('%Y-%m-%d_%H%M')
402
403
404 return self.write(cr, uid, ids, {'state': 'export', 'export_file': out, 'name': 'Libro_Mayor_%s.xls' % (file_time)})
405
406account_report_general_ledger()
407
0408
=== added file 'report_general_ledger_xls/wizard/account_report_ledger_xls_view.xml'
--- report_general_ledger_xls/wizard/account_report_ledger_xls_view.xml 1970-01-01 00:00:00 +0000
+++ report_general_ledger_xls/wizard/account_report_ledger_xls_view.xml 2014-01-29 11:51:34 +0000
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="account_report_general_ledger_view_xls" model="ir.ui.view">
6 <field name="name">Account report general ledger XLS</field>
7 <field name="model">account.report.general.ledger</field>
8 <field name="type">form</field>
9 <field name="inherit_id" ref="account.account_common_report_view" />
10 <field name="arch" type="xml">
11 <data>
12
13 <xpath expr="/form/notebook/page[@name='journal_ids']" position="after">
14 <page string="XLS">
15 <field name="name" invisible="1"/>
16 <field name="export_file" filename="name" />
17 <newline/>
18 <button icon="gtk-print" name="get_report_file_xls" string="Export XLS" type="object" colspan="2" default_focus="1"/>
19 </page>
20 </xpath>
21 </data>
22 </field>
23 </record>
24
25 </data>
26</openerp>