1
# -*- coding: utf-8 -*-
2
from report import report_sxw
6
class report_late_loan(report_sxw.rml_parse):
7
_name = 'report.late.loan'
9
def _get_company(self,cr,uid,context):
11
cids = self.pool.get('res.company').search(cr,uid,[('id','!=',-1)],limit=1)
12
company = self.pool.get('res.company').browse(cr,uid,cids[len(cids)-1])
13
res['name'] = company.name
14
res['city'] = company.city
15
res['register'] = company.company_registry
16
res['street'] = company.street
17
res['phone'] = company.phone
18
res['email'] = company.email
19
res['country'] = company.country_id.name
22
def _get_user(self,cr,uid,context):
23
user = self.pool.get('res.users').browse(cr,uid,uid)
26
def _get_xxz(self,cr,uid,context):
28
from_d = context['from_date']
29
to_d = context['to_date']
30
product_id = context['product']
32
loids = self.pool.get('loan.order').search(cr,uid,[('state','=','paid'),('loan_state','=','d90'),('product_id','=',product_id[0])])
34
loids = self.pool.get('loan.order').search(cr,uid,[('state','=','paid'),('loan_state','=','d90')])
36
for loan in self.pool.get('loan.order').browse(cr,uid,loids):
38
temp = temp + (i,loan.name,loan.partner_id.code,loan.partner_id.name,loan.installment_date,loan.close_date,loan.late_day,loan.amount,loan.loan_balance)
40
lxxids = self.pool.get('loan.xxt.payment').search(cr,uid,[('loan_order','=',loan.id),('state','=','posted')])
42
for lxxp in self.pool.get('loan.xxt.payment').browse(cr,uid,lxxids):
43
xxt0 += lxxp.xxt_payment
45
lpids = self.pool.get('loan.payment').search(cr,uid,[('loan_order','=',loan.id),
46
('date_confirm','>=',from_d),
47
('date_confirm','<=',to_d),
48
('state','=','paid')])
53
for lp in self.pool.get('loan.payment').browse(cr,uid,lpids):
54
loss += lp.loss_payment
59
temp = temp + (xxt0,vz,xt,xxt,loss,loan.issued_economist.name,loan.current_economist.name)
67
def _get_xbz(self,cr,uid,context):
69
product_id = context['product']
71
loids = self.pool.get('loan.order').search(cr,uid,[('state','=','paid'),('loan_state','=','d180'),('product_id','=',product_id[0])])
73
loids = self.pool.get('loan.order').search(cr,uid,[('state','=','paid'),('loan_state','=','d180')])
74
loans = self.pool.get('loan.order').browse(cr,uid,loids)
78
def _get_ez(self,cr,uid,context):
80
product_id = context['product']
82
loids = self.pool.get('loan.order').search(cr,uid,[('state','=','paid'),('loan_state','=','d360'),('product_id','=',product_id[0])])
84
loids = self.pool.get('loan.order').search(cr,uid,[('state','=','paid'),('loan_state','=','d360')])
85
loans = self.pool.get('loan.order').browse(cr,uid,loids)
89
def _get_mz(self,cr,uid,context):
91
product_id = context['product']
93
loids = self.pool.get('loan.order').search(cr,uid,[('state','=','paid'),('loan_state','=','d360g'),('product_id','=',product_id[0])])
95
loids = self.pool.get('loan.order').search(cr,uid,[('state','=','paid'),('loan_state','=','d360g')])
96
loans = self.pool.get('loan.order').browse(cr,uid,loids)
100
def __init__(self, cr, uid, name, context):
101
super(report_late_loan, self).__init__(cr, uid, name, context=context)
102
self.localcontext.update({
104
'from_date':context['from_date'],
105
'to_date':context['to_date'],
106
'company_name': self._get_company(cr,uid,context)['name'],
107
'user':self._get_user(cr,uid,context),
108
'get_xxz':self._get_xxz(cr,uid,context),
109
'get_xbz':self._get_xbz(cr,uid,context),
110
'get_ez':self._get_ez(cr,uid,context),
111
'get_mz':self._get_mz(cr,uid,context),
114
report_sxw.report_sxw('report.late.loan', 'loan.order', 'addons/bbsb_loan/report/report_7_late_loan.rml', parser=report_late_loan, header=False )