22
22
from osv import fields, osv
25
def _code_get(self, cr, uid, context={}):
26
acc_type_obj = self.pool.get('account.account.type')
27
ids = acc_type_obj.search(cr, uid, [])
28
res = acc_type_obj.read(cr, uid, ids, ['code', 'name'], context)
29
return [(r['code'], r['name']) for r in res]
32
25
class account_followup_stat(osv.osv):
33
26
_name = "account_followup.stat"
34
27
_description = "Followup Statistics"
28
_rec_name = 'partner_id'
37
'name': fields.many2one('res.partner', 'Partner', readonly=True),
38
'account_type': fields.selection(_code_get, 'Account Type', readonly=True),
31
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
39
32
'date_move':fields.date('First move', readonly=True),
40
33
'date_move_last':fields.date('Last move', readonly=True),
41
34
'date_followup':fields.date('Latest followup', readonly=True),
58
51
current_year = self.pool.get('account.fiscalyear').find(cr, uid)
59
52
ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
60
53
args.append(['period_id','in',ids])
61
for a in [['period_id','in','current_year']]:
64
args.remove(temp_args)
65
55
return super(account_followup_stat, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
66
56
context=context, count=count)
72
62
current_year = self.pool.get('account.fiscalyear').find(cr, uid)
73
63
ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
74
64
domain.append(['period_id','in',ids])
76
for a in [['period_id','in','current_year']]:
78
if temp_args in domain:
79
domain.remove(temp_args)
80
66
return super(account_followup_stat, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
82
68
def init(self, cr):
83
69
tools.drop_view_if_exists(cr, 'account_followup_stat')
85
71
create or replace view account_followup_stat as (
89
min(l.date) as date_move,
90
max(l.date) as date_move_last,
91
max(l.followup_date) as date_followup,
92
max(l.followup_line_id) as followup_id,
93
sum(l.debit) as debit,
94
sum(l.credit) as credit,
95
sum(l.debit - l.credit) as balance,
96
a.type as account_type,
97
l.company_id as company_id,
99
am.period_id as period_id
74
l.partner_id AS partner_id,
75
min(l.date) AS date_move,
76
max(l.date) AS date_move_last,
77
max(l.followup_date) AS date_followup,
78
max(l.followup_line_id) AS followup_id,
79
sum(l.debit) AS debit,
80
sum(l.credit) AS credit,
81
sum(l.debit - l.credit) AS balance,
82
l.company_id AS company_id,
84
l.period_id AS period_id
101
86
account_move_line l
102
LEFT JOIN account_account a ON (l.account_id=a.id)
103
LEFT JOIN res_company c ON (l.company_id=c.id)
104
LEFT JOIN account_move am ON (am.id=l.move_id)
105
LEFT JOIN account_period p ON (am.period_id=p.id)
107
l.reconcile_id is NULL and
108
a.type = 'receivable'
110
l.partner_id is not NULL and
111
l.company_id is not NULL and
112
l.blocked is not NULL
114
l.partner_id, a.type, l.company_id,l.blocked,am.period_id
87
LEFT JOIN account_account a ON (l.account_id = a.id)
90
a.type = 'receivable' AND
91
l.reconcile_id is NULL AND
92
l.partner_id IS NOT NULL
94
l.id, l.partner_id, l.company_id, l.blocked, l.period_id
116
96
account_followup_stat()
118
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'
98
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: