Modified indicators :added second optional arguement and added tax_code expression

bzr revid: jvo@tinyerp.com-20081107132204-60fe2uxu1wgmxiig
This commit is contained in:
Jay Vora 2008-11-07 18:52:04 +05:30
parent 26da3a62cf
commit 6cc55075f5
3 changed files with 48 additions and 9 deletions

View File

@ -1072,13 +1072,14 @@ class account_tax_code(osv.osv):
return res
def _sum_period(self, cr, uid, ids, name, args, context):
if not 'period_id' in context:
if 'period_id' in context and context['period_id']:
period_id = context['period_id']
else:
period_id = self.pool.get('account.period').find(cr, uid)
if not len(period_id):
return dict.fromkeys(ids, 0.0)
period_id = period_id[0]
else:
period_id = context['period_id']
return self._sum(cr, uid, ids, name, args, context,
where=' and line.period_id='+str(period_id))

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -53,15 +53,44 @@ class account_report(osv.osv):
# ]
def _amount_get(self, cr, uid, ids, field_name, arg, context={}):
def _calc_credit(*code):
obj_fy=self.pool.get('account.fiscalyear')
obj_period=self.pool.get('account.period')
def _calc_context(key,obj):
print "for @@@@@@@@@@@@",obj
if key==0:
print "ddddddddd",obj.find(cr,uid)
return obj.find(cr,uid)
else:
obj_key=obj.browse(cr,uid,obj.find(cr,uid))
print "obj_key",obj_key
key_ids=obj.search(cr,uid,[('date_stop','<',obj_key.date_start)])
if len(key_ids)<abs(key):
print len(key_ids),abs(key)
return False
return key_ids[key]
def _calc_credit(code,year=0):
context['fiscalyear']=False
context['fiscalyear']=_calc_context(year,obj_fy)
if not context['fiscalyear']:
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)
def _calc_debit(*code):
def _calc_debit(code,year=0):
context['fiscalyear']=False
context['fiscalyear']=_calc_context(year,obj_fy)
if not context['fiscalyear']:
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)
def _calc_balance(*code):
def _calc_balance(code,year=0):
context['fiscalyear']=False
context['fiscalyear']=_calc_context(year,obj_fy)
if not context['fiscalyear']:
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)
@ -69,6 +98,14 @@ class account_report(osv.osv):
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)
def _calc_tax_code(code,period=0):
context['period_id']=False
context['period_id']=_calc_context(period,obj_period)
if not context['period_id']:
return 0.00
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)
result = {}
for rep in self.browse(cr, uid, ids, context):
objdict = {
@ -76,6 +113,7 @@ class account_report(osv.osv):
'credit': _calc_credit,
'balance': _calc_balance,
'report': _calc_report,
'tax_code': _calc_tax_code,
}
# if field_name=='status':
# fld_name = 'expression_status'

View File

@ -15,7 +15,7 @@ import tools
from report.render import render
from report.interface import report_int
import os
import pdf_ext
_tax_form = """<?xml version="1.0"?>
<form string="VAT Legal Declaration">
@ -69,7 +69,7 @@ class report_custom(report_int):
result['info_address'] = partner.address[0].street
result['info_address2'] = str(partner.address[0].zip) + ' ' + str(partner.address[0].city)
pdf_ext.fill_pdf(tools.config['addons_path']+'/l10n_lu/wizard/2008_DECL_F_M10.pdf', '/tmp/output.pdf', result)
tools.pdf_utils.fill_pdf(tools.config['addons_path']+'/l10n_lu/wizard/2008_DECL_F_M10.pdf', '/tmp/output.pdf', result)
self.obj = external_pdf(file('/tmp/output.pdf').read())
self.obj.render()
return (self.obj.pdf, 'pdf')