2010-10-28 08:42:58 +00:00
|
|
|
import time
|
|
|
|
from report import report_sxw
|
|
|
|
import pooler
|
2010-11-11 06:11:02 +00:00
|
|
|
|
2010-10-28 08:42:58 +00:00
|
|
|
|
|
|
|
class l10n_chart_it_servabit_report_libroIVA_credito(report_sxw.rml_parse):
|
2010-11-11 06:11:02 +00:00
|
|
|
|
2010-10-28 08:42:58 +00:00
|
|
|
def __init__(self, cr, uid, name, context):
|
|
|
|
super(l10n_chart_it_servabit_report_libroIVA_credito,self).__init__(cr,uid,name,context)
|
|
|
|
self.localcontext.update({
|
2010-11-11 06:11:02 +00:00
|
|
|
'time' : time,
|
2010-10-28 08:42:58 +00:00
|
|
|
'get_company' : self.get_company,
|
|
|
|
'get_periods' : self.get_periods,
|
|
|
|
'get_lines' : self.get_lines,
|
|
|
|
})
|
2010-11-11 06:11:02 +00:00
|
|
|
|
|
|
|
|
2010-10-28 08:42:58 +00:00
|
|
|
def get_company(self,fiscal_year):
|
|
|
|
#print 'COMP = ',fiscal_year
|
|
|
|
return ""
|
2010-11-11 06:11:02 +00:00
|
|
|
|
2010-10-28 08:42:58 +00:00
|
|
|
def get_periods(self,fiscal_year):
|
|
|
|
#print 'Fiscal year id:',fiscal_year.id
|
|
|
|
obj=pooler.get_pool(self.cr.dbname).get('account.fiscalyear')
|
|
|
|
fy=obj.browse(self.cr,self.uid,fiscal_year.id)
|
|
|
|
#print 'Periods = ',fy.period_ids
|
|
|
|
res=[rec for rec in fy.period_ids]
|
|
|
|
#return fy.periods => non funziona?!? bool object !?!?
|
|
|
|
return res
|
2010-11-11 06:11:02 +00:00
|
|
|
|
2010-10-28 08:42:58 +00:00
|
|
|
def get_invoices(self,period):
|
|
|
|
#print 'PERIOD = ',period.name
|
|
|
|
obj=pooler.get_pool(self.cr.dbname).get('account.invoice')
|
|
|
|
# Selezione tutte le fatture emesse nel periodo
|
|
|
|
self.cr.execute( """
|
2010-11-11 06:11:02 +00:00
|
|
|
SELECT id FROM account_invoice
|
2010-10-28 08:42:58 +00:00
|
|
|
WHERE (state='open' OR state='paid') AND
|
|
|
|
period_id="""+str(period.id)+"""
|
|
|
|
AND (type='out_invoice' OR type='out_refund')
|
|
|
|
""")
|
|
|
|
ids=self.cr.fetchall()
|
|
|
|
#print 'IDS = ',
|
|
|
|
if ids:
|
|
|
|
ids=[id[0] for id in ids ]
|
|
|
|
invoices=obj.browse(self.cr,self.uid,ids)
|
|
|
|
#print 'INVOICES = ',invoices
|
|
|
|
return invoices
|
2010-11-11 06:11:02 +00:00
|
|
|
|
2010-10-28 08:42:58 +00:00
|
|
|
def get_lines(self,fiscal_year):
|
|
|
|
res=[]
|
|
|
|
obj_fy=pooler.get_pool(self.cr.dbname).get('account.fiscalyear')
|
|
|
|
fy=obj_fy.browse(self.cr,self.uid,fiscal_year.id)
|
|
|
|
for period in fy.period_ids:
|
|
|
|
invoices=self.get_invoices(period)
|
|
|
|
for invoice in invoices:
|
|
|
|
d={'periodo': period.name}
|
|
|
|
d['protocollo']=invoice.number
|
|
|
|
#print 'PARTNER ',invoice.partner_id.name
|
|
|
|
causale=invoice.partner_id.name
|
|
|
|
#print 'CAUSALE = ',causale
|
|
|
|
d['causale']=causale
|
|
|
|
d['numero']=invoice.reference
|
|
|
|
d['data_doc']=invoice.date_invoice
|
|
|
|
for tax in invoice.tax_line:
|
|
|
|
#print '\tTAX: ',tax
|
|
|
|
d['aliquota']=tax.tax_code_id.name
|
|
|
|
d['imponibile']=tax.base
|
|
|
|
d['imposta']=tax.amount
|
|
|
|
res.append(d)
|
|
|
|
d={'periodo':'', 'protocollo':'', 'causale':'', 'numero':'', 'data_doc':'', }
|
|
|
|
return res
|
|
|
|
|
|
|
|
report_sxw.report_sxw('report.l10n_it.report.libroIVA_credito','account.report_libroiva',
|
|
|
|
'l10n_it/report/libroIVA_credito.rml',
|
|
|
|
parser=l10n_chart_it_servabit_report_libroIVA_credito,header=False)
|
2010-11-11 06:11:02 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|