1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
23 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 class account_followup_stat(osv.osv):
33 _name = "account_followup.stat"
34 _description = "Followup statistics"
37 'name': fields.many2one('res.partner', 'Partner', readonly=True),
38 'account_type': fields.selection(_code_get, 'Account Type', readonly=True),
39 'date_move':fields.date('First move', readonly=True),
40 'date_move_last':fields.date('Last move', readonly=True),
41 'date_followup':fields.date('Latest followup', readonly=True),
42 'followup_id': fields.many2one('account_followup.followup.line',
43 'Follow Ups', readonly=True, ondelete="cascade"),
44 'balance':fields.float('Balance', readonly=True),
45 'debit':fields.float('Debit', readonly=True),
46 'credit':fields.float('Credit', readonly=True),
51 create or replace view account_followup_stat as (
55 min(l.date) as date_move,
56 max(l.date) as date_move_last,
57 max(l.followup_date) as date_followup,
58 max(l.followup_line_id) as followup_id,
59 sum(l.debit) as debit,
60 sum(l.credit) as credit,
61 sum(l.debit - l.credit) as balance,
62 a.type as account_type
66 account_account a on (l.account_id=a.id)
68 l.reconcile_id is NULL and
71 l.partner_id is not null
75 account_followup_stat()
80 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: