3 from report import report_sxw
8 class l10n_chart_it_report_libroIVA_debito(report_sxw.rml_parse):
10 def __init__(self, cr, uid, name, context):
11 super(l10n_chart_it_report_libroIVA_debito,self).__init__(cr,uid,name,context)
12 self.localcontext.update({
14 'get_company' : self.get_company,
15 'get_periods' : self.get_periods,
16 'get_lines' : self.get_lines,
20 def get_company(self,fiscal_year):
21 #print 'COMP = ',fiscal_year
25 def get_periods(self,fiscal_year):
26 #print 'Fiscal year id:',fiscal_year.id
27 obj=pooler.get_pool(self.cr.dbname).get('account.fiscalyear')
28 fy=obj.browse(self.cr,self.uid,fiscal_year.id)
29 #print 'Periods = ',fy.period_ids
30 res=[rec for rec in fy.period_ids]
31 #return fy.periods => non funziona?!? bool object !?!?
34 def get_invoices(self,period):
35 #print 'PERIOD = ',period.name
36 obj=pooler.get_pool(self.cr.dbname).get('account.invoice')
37 # Selezione tutte le fatture emesse nel periodo
39 SELECT id FROM account_invoice
40 WHERE (state='open' OR state='paid') AND
41 period_id="""+str(period.id)+"""
42 AND (type='in_invoice' OR type='in_refund')
44 ids=self.cr.fetchall()
47 ids=[id[0] for id in ids ]
48 invoices=obj.browse(self.cr,self.uid,ids)
49 #print 'INVOICES = ',invoices
52 def get_lines(self,fiscal_year):
54 obj_fy=pooler.get_pool(self.cr.dbname).get('account.fiscalyear')
55 fy=obj_fy.browse(self.cr,self.uid,fiscal_year.id)
56 for period in fy.period_ids:
57 invoices=self.get_invoices(period)
58 for invoice in invoices:
59 d={'periodo': period.name}
60 d['protocollo']=invoice.number
61 #print 'PARTNER ',invoice.partner_id.name
62 causale=invoice.partner_id.name
63 #print 'CAUSALE = ',causale
65 d['numero']=invoice.reference
66 d['data_doc']=invoice.date_invoice
67 for tax in invoice.tax_line:
69 d['aliquota']=tax.tax_code_id.name
70 d['imponibile']=tax.base
71 d['imposta']=tax.amount
73 d={'periodo':'', 'protocollo':'', 'causale':'', 'numero':'', 'data_doc':'', }
78 report_sxw.report_sxw('report.l10n_it.report.libroIVA_debito','account.report_libroiva',
79 'l10n_it/report/libroIVA_debito.rml',
80 parser=l10n_chart_it_report_libroIVA_debito,header=False)