[IMP] Linearization of computation for account_financial_report, necesary with big quantity of data from 90 minutes to 90 secs .... good Job team
commit
8621858924
|
@ -4,7 +4,7 @@
|
|||
# Module Writen to OpenERP, Open Source Management Solution
|
||||
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
|
||||
# All Rights Reserved
|
||||
###############Credits######################################################
|
||||
# Credits######################################################
|
||||
# Coded by: Humberto Arocha <hbto@vauxoo.com>
|
||||
# Planified by: Rafael Silva <rsilvam@vauxoo.com>
|
||||
# Audited by: Nhomar Hernandez <nhomar@vauxoo.com>
|
||||
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
##########################################################################
|
||||
|
||||
import account_financial_report
|
||||
import res_company
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Module Writen to OpenERP, Open Source Management Solution
|
||||
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
|
||||
# All Rights Reserved
|
||||
###############Credits######################################################
|
||||
# Credits######################################################
|
||||
# Coded by: Humberto Arocha humberto@openerp.com.ve
|
||||
# Angelica Barrios angelicaisabelb@gmail.com
|
||||
# Jordi Esteve <jesteve@zikzakmedia.com>
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<pageTemplate id="first">
|
||||
<frame id="first" x1="0.5cm" y1="1.0cm" width="41.0cm" height="23cm"/>
|
||||
<pageGraphics>
|
||||
<setFont name="Helvetica" size="9"/>
|
||||
<setFont name="Helvetica" size="6"/>
|
||||
|
||||
<image x="1.0cm" y="24.0cm" width="5.0cm">[[company.logo and company.logo or removeParentNode('image')]]</image>
|
||||
<!--
|
||||
|
@ -34,7 +34,7 @@
|
|||
</tr>
|
||||
</blockTable>
|
||||
</place>
|
||||
<drawRightString x="192mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
|
||||
<drawRightString x="410.9mm" y="5mm">[[ get_informe_text(data['form']) ]] / Pág.: <pageNumber/>-<pageCount/> </drawRightString>
|
||||
</pageGraphics>
|
||||
|
||||
</pageTemplate>
|
||||
|
@ -64,7 +64,12 @@
|
|||
</blockTableStyle>
|
||||
|
||||
<initialize>
|
||||
<paraStyle name="all" alignment="justify"/>
|
||||
<paraStyle
|
||||
name="all"
|
||||
alignment="justify"
|
||||
fontName="Helvetica"
|
||||
fontSize="6.0"
|
||||
/>
|
||||
</initialize>
|
||||
<paraStyle
|
||||
name="TITLE_LEFT_ALIGN"
|
||||
|
@ -149,79 +154,79 @@
|
|||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal1'] and a['bal1'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal1'] and a['bal1'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal6'] and a['bal6'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal6'] and a['bal6'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal7'] and a['bal7'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal7'] and a['bal7'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal8'] and a['bal8'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal8'] and a['bal8'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal9'] and a['bal9'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal9'] and a['bal9'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal10'] and a['bal10'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal10'] and a['bal10'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal11'] and a['bal11'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal11'] and a['bal11'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal12'] and a['bal12'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal12'] and a['bal12'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal13'] and a['bal13'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal13'] and a['bal13'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -140,7 +140,7 @@
|
|||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -205,7 +205,7 @@
|
|||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -223,7 +223,7 @@
|
|||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -281,7 +281,7 @@
|
|||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(m['balance'] and m['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(m['balance'] and m['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -125,31 +125,31 @@
|
|||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal1'] and a['bal1'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal1'] and (a['bal1'] * a.get('change_sign',1)) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
<td>
|
||||
<para style="TITLE_LEFT_ALIGN">
|
||||
<font>[[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
<font>[[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']]</font>
|
||||
</para>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -35,6 +35,8 @@ from report import report_sxw
|
|||
from tools import config
|
||||
from tools.translate import _
|
||||
from osv import osv
|
||||
import pdb
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
||||
|
||||
class account_balance(report_sxw.rml_parse):
|
||||
|
@ -347,6 +349,8 @@ class account_balance(report_sxw.rml_parse):
|
|||
################################################################
|
||||
# Get the accounts #
|
||||
################################################################
|
||||
all_account_ids = _get_children_and_consol(
|
||||
self.cr, self.uid, account_ids, 100, self.context)
|
||||
|
||||
account_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form[
|
||||
'display_account_level'] and form['display_account_level'] or 100, self.context)
|
||||
|
@ -359,7 +363,6 @@ class account_balance(report_sxw.rml_parse):
|
|||
|
||||
credit_account_ids = list(set(
|
||||
credit_account_ids) - set(debit_account_ids))
|
||||
|
||||
#
|
||||
# Generate the report lines (checking each account)
|
||||
#
|
||||
|
@ -388,21 +391,15 @@ class account_balance(report_sxw.rml_parse):
|
|||
p.append(l)
|
||||
l = []
|
||||
a = 0
|
||||
|
||||
#~ period_ids = p
|
||||
|
||||
elif form['columns'] == 'thirteen':
|
||||
period_ids = period_obj.search(self.cr, self.uid, [(
|
||||
'fiscalyear_id', '=', fiscalyear.id), ('special', '=', False)], order='date_start asc')
|
||||
|
||||
if form['columns'] == 'qtr':
|
||||
tot_bal1 = 0.0
|
||||
tot_bal2 = 0.0
|
||||
tot_bal3 = 0.0
|
||||
tot_bal4 = 0.0
|
||||
tot_bal5 = 0.0
|
||||
|
||||
elif form['columns'] == 'thirteen':
|
||||
period_ids = period_obj.search(self.cr, self.uid, [(
|
||||
'fiscalyear_id', '=', fiscalyear.id), ('special', '=', False)], order='date_start asc')
|
||||
tot_bal1 = 0.0
|
||||
tot_bal1 = 0.0
|
||||
tot_bal2 = 0.0
|
||||
tot_bal3 = 0.0
|
||||
|
@ -416,12 +413,8 @@ class account_balance(report_sxw.rml_parse):
|
|||
tot_bal11 = 0.0
|
||||
tot_bal12 = 0.0
|
||||
tot_bal13 = 0.0
|
||||
|
||||
else:
|
||||
|
||||
ctx_init = _ctx_init(self.context.copy())
|
||||
ctx_end = _ctx_end(self.context.copy())
|
||||
|
||||
tot_bin = 0.0
|
||||
tot_deb = 0.0
|
||||
tot_crd = 0.0
|
||||
|
@ -432,6 +425,117 @@ class account_balance(report_sxw.rml_parse):
|
|||
result_acc = []
|
||||
tot = {}
|
||||
|
||||
###############################################################
|
||||
# Calculations of credit, debit and balance,
|
||||
# without repeating operations.
|
||||
###############################################################
|
||||
|
||||
account_black_ids = account_obj.search(self.cr, self.uid, (
|
||||
[('id', 'in', [i[0] for i in all_account_ids]),
|
||||
('type', 'not in',
|
||||
('view', 'consolidation'))]))
|
||||
|
||||
account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [
|
||||
i[0] for i in all_account_ids]), ('type', 'in', ('view', 'consolidation'))]))
|
||||
|
||||
# This could be done quickly with a sql sentence
|
||||
account_not_black = account_obj.browse(
|
||||
self.cr, self.uid, account_not_black_ids)
|
||||
account_not_black.sort(key=lambda x: x.level)
|
||||
account_not_black.reverse()
|
||||
account_not_black_ids = [i.id for i in account_not_black]
|
||||
|
||||
all_account_period = {} # All accounts per period
|
||||
|
||||
# Iteration limit depending on the number of columns
|
||||
if form['columns'] == 'thirteen':
|
||||
limit = 13
|
||||
elif form['columns'] == 'qtr':
|
||||
limit = 5
|
||||
else:
|
||||
limit = 1
|
||||
|
||||
for p_act in range(limit):
|
||||
if limit != 1:
|
||||
if p_act == limit-1:
|
||||
form['periods'] = period_ids
|
||||
else:
|
||||
if form['columns'] == 'thirteen':
|
||||
form['periods'] = [period_ids[p_act]]
|
||||
elif form['columns'] == 'qtr':
|
||||
form['periods'] = p[p_act]
|
||||
|
||||
if form['inf_type'] == 'IS':
|
||||
ctx_to_use = _ctx_end(self.context.copy())
|
||||
else:
|
||||
ctx_i = _ctx_init(self.context.copy())
|
||||
ctx_to_use = _ctx_end(self.context.copy())
|
||||
|
||||
account_black = account_obj.browse(
|
||||
self.cr, self.uid, account_black_ids, ctx_to_use)
|
||||
|
||||
if form['inf_type'] == 'BS':
|
||||
account_black_init = account_obj.browse(
|
||||
self.cr, self.uid, account_black_ids, ctx_i)
|
||||
|
||||
#~ Black
|
||||
dict_black = {}
|
||||
for i in account_black:
|
||||
d = i.debit
|
||||
c = i.credit
|
||||
dict_black[i.id] = {
|
||||
'obj': i,
|
||||
'debit': d,
|
||||
'credit': c,
|
||||
'balance': d-c
|
||||
}
|
||||
if form['inf_type'] == 'BS':
|
||||
dict_black.get(i.id)['balanceinit'] = 0.0
|
||||
|
||||
# If the report is a balance sheet
|
||||
# Balanceinit values are added to the dictionary
|
||||
if form['inf_type'] == 'BS':
|
||||
for i in account_black_init:
|
||||
dict_black.get(i.id)['balanceinit'] = i.balance
|
||||
|
||||
#~ Not black
|
||||
dict_not_black = {}
|
||||
for i in account_not_black:
|
||||
dict_not_black[i.id] = {
|
||||
'obj': i, 'debit': 0.0, 'credit': 0.0, 'balance': 0.0}
|
||||
if form['inf_type'] == 'BS':
|
||||
dict_not_black.get(i.id)['balanceinit'] = 0.0
|
||||
|
||||
all_account = dict_black.copy(
|
||||
) #It makes a copy because they modify
|
||||
|
||||
for acc_id in account_not_black_ids:
|
||||
acc_childs = dict_not_black.get(acc_id).get('obj').child_id
|
||||
for child_id in acc_childs:
|
||||
dict_not_black.get(acc_id)['debit'] += all_account.get(
|
||||
child_id.id).get('debit')
|
||||
dict_not_black.get(acc_id)['credit'] += all_account.get(
|
||||
child_id.id).get('credit')
|
||||
dict_not_black.get(acc_id)['balance'] += all_account.get(
|
||||
child_id.id).get('balance')
|
||||
if form['inf_type'] == 'BS':
|
||||
dict_not_black.get(acc_id)['balanceinit'] += all_account.get(
|
||||
child_id.id).get('balanceinit')
|
||||
all_account[acc_id] = dict_not_black[acc_id]
|
||||
|
||||
if p_act == limit-1:
|
||||
all_account_period['all'] = all_account
|
||||
else:
|
||||
if form['columns'] == 'thirteen':
|
||||
all_account_period[p_act] = all_account
|
||||
elif form['columns'] == 'qtr':
|
||||
all_account_period[p_act] = all_account
|
||||
|
||||
###############################################################
|
||||
# End of the calculations of credit, debit and balance
|
||||
#
|
||||
###############################################################
|
||||
|
||||
for aa_id in account_ids:
|
||||
id = aa_id[0]
|
||||
|
||||
|
@ -452,21 +556,11 @@ class account_balance(report_sxw.rml_parse):
|
|||
}
|
||||
|
||||
if form['columns'] == 'qtr':
|
||||
pn = 1
|
||||
for p_id in p:
|
||||
form['periods'] = p_id
|
||||
|
||||
ctx_init = _ctx_init(self.context.copy())
|
||||
aa_brw_init = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_init)
|
||||
|
||||
ctx_end = _ctx_end(self.context.copy())
|
||||
aa_brw_end = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_end)
|
||||
for pn in range(1, 5):
|
||||
|
||||
if form['inf_type'] == 'IS':
|
||||
d, c, b = map(z, [
|
||||
aa_brw_end.debit, aa_brw_end.credit, aa_brw_end.balance])
|
||||
all_account_period.get(pn-1).get(id).get('debit', 0.0), all_account_period.get(pn-1).get(id).get('credit', 0.0), all_account_period.get(pn-1).get(id).get('balance', 0.0)])
|
||||
res.update({
|
||||
'dbr%s' % pn: self.exchange(d),
|
||||
'cdr%s' % pn: self.exchange(c),
|
||||
|
@ -474,7 +568,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
})
|
||||
else:
|
||||
i, d, c = map(z, [
|
||||
aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit])
|
||||
all_account_period.get(pn-1).get(id).get('balanceinit', 0.0), all_account_period.get(pn-1).get(id).get('debit', 0.0), all_account_period.get(pn-1).get(id).get('credit', 0.0)])
|
||||
b = z(i+d-c)
|
||||
res.update({
|
||||
'dbr%s' % pn: self.exchange(d),
|
||||
|
@ -482,21 +576,9 @@ class account_balance(report_sxw.rml_parse):
|
|||
'bal%s' % pn: self.exchange(b),
|
||||
})
|
||||
|
||||
pn += 1
|
||||
|
||||
form['periods'] = period_ids
|
||||
|
||||
ctx_init = _ctx_init(self.context.copy())
|
||||
aa_brw_init = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_init)
|
||||
|
||||
ctx_end = _ctx_end(self.context.copy())
|
||||
aa_brw_end = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_end)
|
||||
|
||||
if form['inf_type'] == 'IS':
|
||||
d, c, b = map(z, [
|
||||
aa_brw_end.debit, aa_brw_end.credit, aa_brw_end.balance])
|
||||
all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit',0.0), all_account_period.get('all').get(id).get('balance')])
|
||||
res.update({
|
||||
'dbr5': self.exchange(d),
|
||||
'cdr5': self.exchange(c),
|
||||
|
@ -504,7 +586,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
})
|
||||
else:
|
||||
i, d, c = map(z, [
|
||||
aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit])
|
||||
all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit',0.0)])
|
||||
b = z(i+d-c)
|
||||
res.update({
|
||||
'dbr5': self.exchange(d),
|
||||
|
@ -514,20 +596,11 @@ class account_balance(report_sxw.rml_parse):
|
|||
|
||||
elif form['columns'] == 'thirteen':
|
||||
pn = 1
|
||||
for p_id in period_ids:
|
||||
form['periods'] = [p_id]
|
||||
|
||||
ctx_init = _ctx_init(self.context.copy())
|
||||
aa_brw_init = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_init)
|
||||
|
||||
ctx_end = _ctx_end(self.context.copy())
|
||||
aa_brw_end = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_end)
|
||||
for p_num in range(12):
|
||||
|
||||
if form['inf_type'] == 'IS':
|
||||
d, c, b = map(z, [
|
||||
aa_brw_end.debit, aa_brw_end.credit, aa_brw_end.balance])
|
||||
all_account_period.get(p_num).get(id).get('debit', 0.0), all_account_period.get(p_num).get(id).get('credit', 0.0), all_account_period.get(p_num).get(id).get('balance', 0.0)])
|
||||
res.update({
|
||||
'dbr%s' % pn: self.exchange(d),
|
||||
'cdr%s' % pn: self.exchange(c),
|
||||
|
@ -535,7 +608,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
})
|
||||
else:
|
||||
i, d, c = map(z, [
|
||||
aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit])
|
||||
all_account_period.get(p_num).get(id).get('balanceinit', 0.0), all_account_period.get(p_num).get(id).get('debit', 0.0), all_account_period.get(p_num).get(id).get('credit', 0.0)])
|
||||
b = z(i+d-c)
|
||||
res.update({
|
||||
'dbr%s' % pn: self.exchange(d),
|
||||
|
@ -545,19 +618,9 @@ class account_balance(report_sxw.rml_parse):
|
|||
|
||||
pn += 1
|
||||
|
||||
form['periods'] = period_ids
|
||||
|
||||
ctx_init = _ctx_init(self.context.copy())
|
||||
aa_brw_init = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_init)
|
||||
|
||||
ctx_end = _ctx_end(self.context.copy())
|
||||
aa_brw_end = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_end)
|
||||
|
||||
if form['inf_type'] == 'IS':
|
||||
d, c, b = map(z, [
|
||||
aa_brw_end.debit, aa_brw_end.credit, aa_brw_end.balance])
|
||||
all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0), all_account_period.get('all').get(id).get('balance', 0.0)])
|
||||
res.update({
|
||||
'dbr13': self.exchange(d),
|
||||
'cdr13': self.exchange(c),
|
||||
|
@ -565,7 +628,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
})
|
||||
else:
|
||||
i, d, c = map(z, [
|
||||
aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit])
|
||||
all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0)])
|
||||
b = z(i+d-c)
|
||||
res.update({
|
||||
'dbr13': self.exchange(d),
|
||||
|
@ -574,14 +637,8 @@ class account_balance(report_sxw.rml_parse):
|
|||
})
|
||||
|
||||
else:
|
||||
|
||||
aa_brw_init = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_init)
|
||||
aa_brw_end = account_obj.browse(
|
||||
self.cr, self.uid, id, ctx_end)
|
||||
|
||||
i, d, c = map(z, [
|
||||
aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit])
|
||||
all_account_period.get('all').get(id).get('balanceinit', 0.0), all_account_period.get('all').get(id).get('debit', 0.0), all_account_period.get('all').get(id).get('credit', 0.0)])
|
||||
b = z(i+d-c)
|
||||
res.update({
|
||||
'balanceinit': self.exchange(i),
|
||||
|
@ -695,7 +752,6 @@ class account_balance(report_sxw.rml_parse):
|
|||
tot_bal11 += res.get('bal11', 0.0)
|
||||
tot_bal12 += res.get('bal12', 0.0)
|
||||
tot_bal13 += res.get('bal13', 0.0)
|
||||
|
||||
else:
|
||||
tot_check = True
|
||||
#~ tot[res['id']] = True
|
||||
|
@ -715,26 +771,26 @@ class account_balance(report_sxw.rml_parse):
|
|||
}
|
||||
if form['columns'] == 'qtr':
|
||||
res2.update(dict(
|
||||
bal1=tot_bal1,
|
||||
bal2=tot_bal2,
|
||||
bal3=tot_bal3,
|
||||
bal4=tot_bal4,
|
||||
bal5=tot_bal5,))
|
||||
bal1=z(tot_bal1),
|
||||
bal2=z(tot_bal2),
|
||||
bal3=z(tot_bal3),
|
||||
bal4=z(tot_bal4),
|
||||
bal5=z(tot_bal5),))
|
||||
elif form['columns'] == 'thirteen':
|
||||
res2.update(dict(
|
||||
bal1=tot_bal1,
|
||||
bal2=tot_bal2,
|
||||
bal3=tot_bal3,
|
||||
bal4=tot_bal4,
|
||||
bal5=tot_bal5,
|
||||
bal6=tot_bal6,
|
||||
bal7=tot_bal7,
|
||||
bal8=tot_bal8,
|
||||
bal9=tot_bal9,
|
||||
bal10=tot_bal10,
|
||||
bal11=tot_bal11,
|
||||
bal12=tot_bal12,
|
||||
bal13=tot_bal13,))
|
||||
bal1=z(tot_bal1),
|
||||
bal2=z(tot_bal2),
|
||||
bal3=z(tot_bal3),
|
||||
bal4=z(tot_bal4),
|
||||
bal5=z(tot_bal5),
|
||||
bal6=z(tot_bal6),
|
||||
bal7=z(tot_bal7),
|
||||
bal8=z(tot_bal8),
|
||||
bal9=z(tot_bal9),
|
||||
bal10=z(tot_bal10),
|
||||
bal11=z(tot_bal11),
|
||||
bal12=z(tot_bal12),
|
||||
bal13=z(tot_bal13),))
|
||||
|
||||
else:
|
||||
res2.update({
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Module Writen to OpenERP, Open Source Management Solution
|
||||
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
|
||||
# All Rights Reserved
|
||||
###############Credits######################################################
|
||||
# Credits######################################################
|
||||
# Coded by: Humberto Arocha humberto@openerp.com.ve
|
||||
# Angelica Barrios angelicaisabelb@gmail.com
|
||||
# Jordi Esteve <jesteve@zikzakmedia.com>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Module Writen to OpenERP, Open Source Management Solution
|
||||
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
|
||||
# All Rights Reserved
|
||||
###############Credits######################################################
|
||||
# Credits######################################################
|
||||
# Coded by: Humberto Arocha humberto@openerp.com.ve
|
||||
# Angelica Barrios angelicaisabelb@gmail.com
|
||||
# Jordi Esteve <jesteve@zikzakmedia.com>
|
||||
|
@ -31,6 +31,7 @@ import pooler
|
|||
import time
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class wizard_report(osv.osv_memory):
|
||||
_name = "wizard.report"
|
||||
|
||||
|
@ -87,7 +88,8 @@ class wizard_report(osv.osv_memory):
|
|||
res = {'value': {}}
|
||||
|
||||
p_obj = self.pool.get("account.period")
|
||||
all_periods = p_obj.search(cr,uid,[('fiscalyear_id','=',fiscalyear),('special','=',False)],context=context)
|
||||
all_periods = p_obj.search(cr, uid, [('fiscalyear_id', '=', fiscalyear), (
|
||||
'special', '=', False)], context=context)
|
||||
s = set(periods[0][2])
|
||||
t = set(all_periods)
|
||||
go = periods[0][2] and s.issubset(t) or False
|
||||
|
@ -109,7 +111,8 @@ class wizard_report(osv.osv_memory):
|
|||
context = {}
|
||||
context['company_id'] = company_id
|
||||
res = {'value': {}}
|
||||
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
|
||||
cur_id = self.pool.get('res.company').browse(
|
||||
cr, uid, company_id, context=context).currency_id.id
|
||||
res['value'].update({'currency_id': cur_id})
|
||||
return res
|
||||
|
||||
|
@ -122,8 +125,10 @@ class wizard_report(osv.osv_memory):
|
|||
if not company_id:
|
||||
return res
|
||||
|
||||
cur_id = self.pool.get('res.company').browse(cr,uid,company_id,context=context).currency_id.id
|
||||
fy_id = self.pool.get('account.fiscalyear').find(cr, uid,context=context)
|
||||
cur_id = self.pool.get('res.company').browse(
|
||||
cr, uid, company_id, context=context).currency_id.id
|
||||
fy_id = self.pool.get('account.fiscalyear').find(
|
||||
cr, uid, context=context)
|
||||
res['value'].update({'fiscalyear': fy_id})
|
||||
res['value'].update({'currency_id': cur_id})
|
||||
res['value'].update({'account_list': []})
|
||||
|
@ -135,29 +140,39 @@ class wizard_report(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
res = {'value': {}}
|
||||
if not afr_id: return res
|
||||
if not afr_id:
|
||||
return res
|
||||
afr_brw = self.pool.get('afr').browse(cr, uid, afr_id, context=context)
|
||||
res['value'].update({'currency_id':afr_brw.currency_id and afr_brw.currency_id.id or afr_brw.company_id.currency_id.id})
|
||||
res['value'].update({
|
||||
'currency_id': afr_brw.currency_id and afr_brw.currency_id.id or afr_brw.company_id.currency_id.id})
|
||||
res['value'].update({'inf_type': afr_brw.inf_type or 'BS'})
|
||||
res['value'].update({'columns': afr_brw.columns or 'five'})
|
||||
res['value'].update({'display_account':afr_brw.display_account or 'bal_mov'})
|
||||
res['value'].update({'display_account_level':afr_brw.display_account_level or 0})
|
||||
res['value'].update({'fiscalyear':afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id})
|
||||
res['value'].update({'account_list':[acc.id for acc in afr_brw.account_ids]})
|
||||
res['value'].update({
|
||||
'display_account': afr_brw.display_account or 'bal_mov'})
|
||||
res['value'].update({
|
||||
'display_account_level': afr_brw.display_account_level or 0})
|
||||
res['value'].update({
|
||||
'fiscalyear': afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id})
|
||||
res['value'].update({'account_list': [
|
||||
acc.id for acc in afr_brw.account_ids]})
|
||||
res['value'].update({'periods': [p.id for p in afr_brw.period_ids]})
|
||||
res['value'].update({'analytic_ledger':afr_brw.analytic_ledger or False})
|
||||
res['value'].update({
|
||||
'analytic_ledger': afr_brw.analytic_ledger or False})
|
||||
res['value'].update({'tot_check': afr_brw.tot_check or False})
|
||||
res['value'].update({'lab_str':afr_brw.lab_str or _('Write a Description for your Summary Total')})
|
||||
res['value'].update({'lab_str': afr_brw.lab_str or _(
|
||||
'Write a Description for your Summary Total')})
|
||||
return res
|
||||
|
||||
def _get_defaults(self, cr, uid, data, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
|
||||
user = pooler.get_pool(cr.dbname).get(
|
||||
'res.users').browse(cr, uid, uid, context=context)
|
||||
if user.company_id:
|
||||
company_id = user.company_id.id
|
||||
else:
|
||||
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
company_id = pooler.get_pool(cr.dbname).get(
|
||||
'res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
data['form']['company_id'] = company_id
|
||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||
|
@ -176,7 +191,8 @@ class wizard_report(osv.osv_memory):
|
|||
context = {}
|
||||
|
||||
if data['form']['date_from'] > data['form']['date_to']:
|
||||
raise osv.except_osv(_('Error !'),('La fecha final debe ser mayor a la inicial'))
|
||||
raise osv.except_osv(_('Error !'), (
|
||||
'La fecha final debe ser mayor a la inicial'))
|
||||
|
||||
sql = """SELECT f.id, f.date_start, f.date_stop
|
||||
FROM account_fiscalyear f
|
||||
|
@ -186,7 +202,8 @@ class wizard_report(osv.osv_memory):
|
|||
|
||||
if res:
|
||||
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_from'] < res[0]['date_start']):
|
||||
raise osv.except_osv(_('UserError'),'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop']))
|
||||
raise osv.except_osv(_('UserError'), 'Las fechas deben estar entre %s y %s' % (
|
||||
res[0]['date_start'], res[0]['date_stop']))
|
||||
else:
|
||||
return 'report'
|
||||
else:
|
||||
|
@ -220,7 +237,8 @@ class wizard_report(osv.osv_memory):
|
|||
del data['form']['date_from']
|
||||
del data['form']['date_to']
|
||||
|
||||
data['form']['periods'] = self.period_span(cr, uid, data['form']['periods'], data['form']['fiscalyear'])
|
||||
data['form']['periods'] = self.period_span(cr, uid, data[
|
||||
'form']['periods'], data['form']['fiscalyear'])
|
||||
|
||||
elif data['form']['filter'] == 'bydate':
|
||||
self._check_date(cr, uid, data)
|
||||
|
@ -231,7 +249,8 @@ class wizard_report(osv.osv_memory):
|
|||
del data['form']['periods']
|
||||
else:
|
||||
self._check_date(cr, uid, data)
|
||||
lis2 = str(data['form']['periods']).replace("[","(").replace("]",")")
|
||||
lis2 = str(data['form']['periods']).replace(
|
||||
"[", "(").replace("]", ")")
|
||||
sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin
|
||||
from account_period p
|
||||
where p.id in %s""" % lis2
|
||||
|
@ -239,7 +258,8 @@ class wizard_report(osv.osv_memory):
|
|||
minmax = cr.dictfetchall()
|
||||
if minmax:
|
||||
if (data['form']['date_to'] < minmax[0]['inicio']) or (data['form']['date_from'] > minmax[0]['fin']):
|
||||
raise osv.except_osv(_('Error !'),_('La interseccion entre el periodo y fecha es vacio'))
|
||||
raise osv.except_osv(_('Error !'), _(
|
||||
'La interseccion entre el periodo y fecha es vacio'))
|
||||
|
||||
if data['form']['columns'] == 'one':
|
||||
name = 'afr.1cols'
|
||||
|
|
Loading…
Reference in New Issue