[IMP] upgrade translation files
[odoo/odoo.git] / addons / report_analytic / report_analytic.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution   
5 #    Copyright (C) 2004-2008 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 class report_analytic_account_close(osv.osv):
26     _name = "report.analytic.account.close"
27     _description = "Analytic account to close"
28     _auto = False
29     _columns = {
30         'name': fields.many2one('account.analytic.account', 'Analytic account', readonly=True),
31         'state': fields.char('State', size=32, readonly=True),
32         'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
33         'quantity': fields.float('Quantity', readonly=True),
34         'quantity_max': fields.float('Max. Quantity', readonly=True),
35         'balance': fields.float('Balance', readonly=True),
36         'date_deadline': fields.date('Deadline', readonly=True),
37     }
38     def init(self, cr):
39         cr.execute("""
40             create or replace view report_analytic_account_close as (
41                 select
42                     a.id as id,
43                     a.id as name,
44                     a.state as state,
45                     sum(l.unit_amount) as quantity,
46                     sum(l.amount) as balance,
47                     a.partner_id as partner_id,
48                     a.quantity_max as quantity_max,
49                     a.date as date_deadline
50                 from
51                     account_analytic_line l
52                 right join
53                     account_analytic_account a on (l.account_id=a.id)
54                 group by
55                     a.id,a.state, a.quantity_max,a.date,a.partner_id
56                 having
57                     (a.quantity_max>0 and (sum(l.unit_amount)>=a.quantity_max)) or
58                     a.date <= current_date
59             )""")
60 report_analytic_account_close()
61
62 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
63