[IMP] Update the translations
[odoo/odoo.git] / addons / report_account / report_receivable.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 report_account_receivable(osv.osv):
33     _name = "report.account.receivable"
34     _description = "Receivable accounts"
35     _auto = False
36     _columns = {
37         'name': fields.char('Week of Year', size=7, readonly=True),
38         'type': fields.selection(_code_get, 'Account Type', required=True),
39         'balance':fields.float('Balance', readonly=True),
40         'debit':fields.float('Debit', readonly=True),
41         'credit':fields.float('Credit', readonly=True),
42     }
43     _order = 'name desc'
44     def init(self, cr):
45         cr.execute("""
46             create or replace view report_account_receivable as (
47                 select
48                     min(l.id) as id,
49                     to_char(date,'YYYY:IW') as name,
50                     sum(l.debit-l.credit) as balance,
51                     sum(l.debit) as debit,
52                     sum(l.credit) as credit,
53                     a.type
54                 from
55                     account_move_line l
56                 left join
57                     account_account a on (l.account_id=a.id)
58                 where
59                     l.state <> 'draft'
60                 group by
61                     to_char(date,'YYYY:IW'), a.type
62             )""")
63 report_account_receivable()
64
65                     #a.type in ('receivable','payable')
66
67
68 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
69