[I18N] Improve the translations
[odoo/odoo.git] / addons / account_followup / followup_report.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution   
5 #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
6 #    $Id$
7 #
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.
12 #
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.
17 #
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/>.
20 #
21 ##############################################################################
22
23 from osv import fields, osv
24
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]
30
31
32 class account_followup_stat(osv.osv):
33     _name = "account_followup.stat"
34     _description = "Followup statistics"
35     _auto = False
36     _columns = {
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),
47     }
48     _order = 'date_move'
49     def init(self, cr):
50         cr.execute("""
51             create or replace view account_followup_stat as (
52                 select
53                     l.partner_id as id,
54                     l.partner_id as name,
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
63                 from
64                     account_move_line l
65                 left join
66                     account_account a on (l.account_id=a.id)
67                 where
68                     l.reconcile_id is NULL and
69                     a.type = 'receivable'
70                     and a.active and
71                     l.partner_id is not null
72                 group by
73                     l.partner_id, a.type
74             )""")
75 account_followup_stat()
76
77
78
79
80 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
81