1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2008 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 class report_analytic_account_close(osv.osv):
26 _name = "report.analytic.account.close"
27 _description = "Analytic account to close"
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),
40 create or replace view report_analytic_account_close as (
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
51 account_analytic_line l
53 account_analytic_account a on (l.account_id=a.id)
55 a.id,a.state, a.quantity_max,a.date,a.partner_id
57 (a.quantity_max>0 and (sum(l.unit_amount)>=a.quantity_max)) or
58 a.date <= current_date
60 report_analytic_account_close()
62 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: