2 from report import report_sxw
6 class l10n_chart_it_servabit_report_libroIVA_credito(report_sxw.rml_parse):
8 def __init__(self, cr, uid, name, context):
9 super(l10n_chart_it_servabit_report_libroIVA_credito,self).__init__(cr,uid,name,context)
10 self.localcontext.update({
12 'get_company': self.get_company,
13 'get_periods': self.get_periods,
14 'get_lines': self.get_lines,
17 def get_company(self,fiscal_year):
18 #print 'COMP = ',fiscal_year
21 def get_periods(self,fiscal_year):
22 #print 'Fiscal year id:',fiscal_year.id
23 obj=pooler.get_pool(self.cr.dbname).get('account.fiscalyear')
24 fy=obj.browse(self.cr,self.uid,fiscal_year.id)
25 #print 'Periods = ',fy.period_ids
26 res=[rec for rec in fy.period_ids]
27 #return fy.periods => non funziona?!? bool object !?!?
30 def get_invoices(self,period):
31 #print 'PERIOD = ',period.name
32 obj=pooler.get_pool(self.cr.dbname).get('account.invoice')
33 # Selezione tutte le fatture emesse nel periodo
35 SELECT id FROM account_invoice
36 WHERE (state='open' OR state='paid') AND period_id="""+str(period.id)+""" AND (type='out_invoice' OR type='out_refund')
38 ids=self.cr.fetchall()
41 ids=[id[0] for id in ids ]
42 invoices=obj.browse(self.cr,self.uid,ids)
43 #print 'INVOICES = ',invoices
46 def get_lines(self,fiscal_year):
48 obj_fy=pooler.get_pool(self.cr.dbname).get('account.fiscalyear')
49 fy=obj_fy.browse(self.cr,self.uid,fiscal_year.id)
50 for period in fy.period_ids:
51 invoices=self.get_invoices(period)
52 for invoice in invoices:
53 d={'periodo': period.name}
54 d['protocollo']=invoice.number
55 #print 'PARTNER ',invoice.partner_id.name
56 causale=invoice.partner_id.name
57 #print 'CAUSALE = ',causale
59 d['numero']=invoice.reference
60 d['data_doc']=invoice.date_invoice
61 for tax in invoice.tax_line:
63 d['aliquota']=tax.tax_code_id.name
64 d['imponibile']=tax.base
65 d['imposta']=tax.amount
67 d={'periodo':'', 'protocollo':'', 'causale':'', 'numero':'', 'data_doc':'', }
70 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)
72 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: