diff --git a/addons/account_analytic_plans/__terp__.py b/addons/account_analytic_plans/__terp__.py index 6fa9334c35a..b859645cd0a 100644 --- a/addons/account_analytic_plans/__terp__.py +++ b/addons/account_analytic_plans/__terp__.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -20,7 +20,7 @@ # ############################################################################## { - "name" : "Multiple-plans management in analytic accounting", + "name" : "Multiple-plans management in Analytic Accounting", "version" : "1.0", "depends" : ["account", "account_analytic_default"], "author" : "Tiny", diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index 4b6ab06e827..73b5f4bc815 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -135,12 +135,14 @@ class account_analytic_plan_instance(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False): wiz_id = self.pool.get('ir.actions.wizard').search(cr, uid, [("wiz_name","=","create.model")]) res = super(account_analytic_plan_instance,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar) + if (res['type']=='form'): plan_id = False if context.get('journal_id',False): plan_id = self.pool.get('account.journal').browse(cr, uid, int(context['journal_id']), context).plan_id elif context.get('plan_id',False): - plan_id = self.pool.get('account.analytic.plan').browse(cr, uid, int(context['plan_id']), context).plan_id + plan_id = self.pool.get('account.analytic.plan').browse(cr, uid, int(context['plan_id']), context) + if plan_id: i=1 res['arch'] = """
@@ -325,8 +327,6 @@ class account_invoice(osv.osv): _name = "account.invoice" _inherit="account.invoice" - - def line_get_convert(self, cr, uid, x, part, date, context={}): res=super(account_invoice,self).line_get_convert(cr, uid, x, part, date, context) res['analytics_id']=x.get('analytics_id',False) diff --git a/addons/account_analytic_plans/account_analytic_plans_view.xml b/addons/account_analytic_plans/account_analytic_plans_view.xml index cdfa31b7a47..a211f633e9b 100644 --- a/addons/account_analytic_plans/account_analytic_plans_view.xml +++ b/addons/account_analytic_plans/account_analytic_plans_view.xml @@ -115,7 +115,7 @@ diff --git a/addons/account_report/account.py b/addons/account_report/account.py index 0682a1100be..20c933fae91 100644 --- a/addons/account_report/account.py +++ b/addons/account_report/account.py @@ -74,7 +74,7 @@ class account_report(osv.osv): del context['fiscalyear'] acc = self.pool.get('account.account') acc_id = acc.search(cr, uid, [('code','in',code)]) - return reduce(lambda y,x=0: x.credit+y, acc.browse(cr, uid, acc_id, context),0) + return reduce(lambda y,x=0: x.credit+y, acc.browse(cr, uid, acc_id, context),0.0) def _calc_debit(code,year=0): context['fiscalyear']=_calc_context(year,obj_fy) @@ -82,7 +82,7 @@ class account_report(osv.osv): del context['fiscalyear'] acc = self.pool.get('account.account') acc_id = acc.search(cr, uid, [('code','in',code)]) - return reduce(lambda y,x=0: x.debit+y, acc.browse(cr, uid, acc_id, context),0) + return reduce(lambda y,x=0: x.debit+y, acc.browse(cr, uid, acc_id, context),0.0) def _calc_balance(code,year=0): context['fiscalyear']=_calc_context(year,obj_fy) @@ -90,12 +90,12 @@ class account_report(osv.osv): del context['fiscalyear'] acc = self.pool.get('account.account') acc_id = acc.search(cr, uid, [('code','in',code)]) - return reduce(lambda y,x=0: x.balance+y, acc.browse(cr, uid, acc_id, context),0) + return reduce(lambda y,x=0: x.balance+y, acc.browse(cr, uid, acc_id, context),0.0) def _calc_report(*code): acc = self.pool.get('account.report.report') acc_id = acc.search(cr, uid, [('code','in',code)]) - return reduce(lambda y,x=0: x.amount+y, acc.browse(cr, uid, acc_id, context),0) + return reduce(lambda y,x=0: x.amount+y, acc.browse(cr, uid, acc_id, context),0.0) def _calc_tax_code(code,period=0): context['period_id']=_calc_context(period,obj_period) @@ -104,7 +104,7 @@ class account_report(osv.osv): context['period_id']=context['period_id'][0] acc = self.pool.get('account.tax.code') acc_id = acc.search(cr, uid, [('code','in',code)]) - return reduce(lambda y,x=0: x.sum_period+y, acc.browse(cr, uid, acc_id, context),0) + return reduce(lambda y,x=0: x.sum_period+y, acc.browse(cr, uid, acc_id, context),0.0) result = {} for rep in self.browse(cr, uid, ids, context): objdict = { diff --git a/addons/account_report/account_report.xml b/addons/account_report/account_report.xml index b105fae4cf4..94bd6f5fc11 100755 --- a/addons/account_report/account_report.xml +++ b/addons/account_report/account_report.xml @@ -5,5 +5,12 @@ + diff --git a/addons/account_report/account_wizard.xml b/addons/account_report/account_wizard.xml index 63d4303f0c5..84404f461ab 100644 --- a/addons/account_report/account_wizard.xml +++ b/addons/account_report/account_wizard.xml @@ -3,5 +3,8 @@ + + + \ No newline at end of file diff --git a/addons/account_report/report/print_indicator.py b/addons/account_report/report/print_indicator.py index 43960f1df6a..9d990d4a22d 100644 --- a/addons/account_report/report/print_indicator.py +++ b/addons/account_report/report/print_indicator.py @@ -96,6 +96,7 @@ class accounting_report_indicator(report_sxw.rml_parse): self.treecount=0 self.list=[] self.header_name=self.header_val=[] + self.main_dict={} def repeatIn(self, lst, name, nodes_parent=False,td=False,width=[],value=[],type=[]): self._node.data = '' @@ -202,39 +203,62 @@ class accounting_report_indicator(report_sxw.rml_parse): theme.default_font_size = 12 - tb = text_box.T(loc=(0,700),line_style=line_style.darkblue,text=str(obj_history.code)) - - base_x=100 - base_y=700 - - if obj_history.child_ids: - tb.add_arrow((100, 700)) - can.line(line_style.black,base_x-30,base_y,base_x-30,base_y-(50*(len(obj_history.child_ids)-1))) - tb.draw() self.child_dist=0 - def draw_tree(obj_his,base_x,base_y,level=0): - self.child_dist=0 - for i in range(len(obj_his.child_ids)): - can.line(line_style.black,base_x-30,base_y,base_x-30,base_y-(50*(i+len(obj_his.child_ids[i].child_ids)))) - if i<>0: - a = arrow.T(head_style = 1) - if self.child_dist: - diff=self.child_dist - else: - diff=self.child_dist+i - a.draw([(base_x-(30),base_y-(50*diff)), (base_x,base_y-(50*diff))]) - if obj_his.child_ids[i].child_ids: - tb12 = text_box.T(loc=(base_x,base_y-(50*(self.child_dist))), text=str(obj_his.child_ids[i].code)) - tb12.add_arrow((base_x+(100*(level+1)),base_y-(50*(self.child_dist)))) - tb12.draw() - draw_tree(obj_his.child_ids[i],base_x+(100*(level+1)),base_y-(50*(self.child_dist)),level+1) + level=0 + self.level=0 + self.child_dist=0 + + def draw_tree(obj_history,base_x,base_y,level=0,i=0): + self.line_y=base_y + if obj_history.child_ids: + if self.child_dist: + diff=i*self.child_dist + self.child_dist=0 else: - tb12 = text_box.T(loc=(base_x,base_y-(50*(i+self.child_dist))), text=str(obj_his.child_ids[i].code)) - tb12.draw() - self.child_dist=len(obj_his.child_ids[i].child_ids) -# - draw_tree(obj_history,base_x,base_y,0) + diff=i + if self.level>0 and (base_y-(50*diff)) >= self.level: + base_y=self.level-(50*i) + else: + base_y=base_y-(50*diff) + tb = text_box.T(loc=(base_x,base_y),line_style=line_style.darkblue,text="/hC"+str(obj_history.code)+":\n"+str(obj_history.amount)) + + tb.add_arrow((base_x+100,base_y)) + tb.draw() + + if level!=0: + a = arrow.T(head_style = 1) + a.draw([(base_x-30,base_y), (base_x,base_y)]) + level+=1 + + if i>0: + can.line(line_style.black,base_x-30,base_y,base_x-30,self.line_y) + + i=0 + for child in obj_history.child_ids: + draw_tree(child,base_x+(100),base_y,level,i) + i+=1 + + child_dist=len(obj_history.child_ids) + self.child_dist=max(self.child_dist,child_dist) + + else: + + if self.level>0 and (base_y-(50*i)) >= self.level: + base_y=self.level-(50) + else: + base_y=base_y-(50*(i)) + + tb12 = text_box.T(loc=(base_x,base_y), text="/hC"+str(obj_history.code)+":\n"+str(obj_history.amount)) + tb12.draw() + + if i>0: + can.line(line_style.black,base_x-30,base_y,base_x-30,self.line_y) + a = arrow.T(head_style = 1) + a.draw([(base_x-30,base_y), (base_x,base_y)]) + self.level=base_y + self.line_y=900 + draw_tree(obj_history,0,900,0) can.close() os.system('cp '+'tree_image'+str(self.treecount)+'.png ' +path+str(self.treecount)+'.png') diff --git a/addons/account_report/wizard/__init__.py b/addons/account_report/wizard/__init__.py index 5689089dae4..042065595e9 100644 --- a/addons/account_report/wizard/__init__.py +++ b/addons/account_report/wizard/__init__.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved # $Id$ # @@ -21,5 +21,6 @@ ############################################################################## import wizard_print_indicators +import wizard_print_indicators_with_pdf # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_report/wizard/wizard_print_indicators_with_pdf.py b/addons/account_report/wizard/wizard_print_indicators_with_pdf.py new file mode 100644 index 00000000000..2371f912b62 --- /dev/null +++ b/addons/account_report/wizard/wizard_print_indicators_with_pdf.py @@ -0,0 +1,109 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import wizard +import pooler +import time +import datetime +import sys +from mx.DateTime import * +import tools +from report.render import render +from report.interface import report_int +import os +import base64 +import StringIO + +form = ''' + +