Launchpad automatic translations update.
[odoo/odoo.git] / addons / point_of_sale / report / report_cash_register.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 import tools
23 from osv import fields,osv
24
25 class report_cash_register(osv.osv):
26     _name = "report.cash.register"
27     _description = "Point of Sale Cash Register Analysis"
28     _auto = False
29     _columns = {
30         'date': fields.date('Create Date', readonly=True),
31         'year': fields.char('Year', size=4),
32         'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
33             ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
34             ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
35         'day': fields.char('Day', size=128, readonly=True),
36         'user_id':fields.many2one('res.users', 'User', readonly=True),
37         'state': fields.selection([('draft', 'Quotation'),('open','Open'),('confirm', 'Confirmed')],'State'),
38         'journal_id': fields.many2one('account.journal', 'Journal'),
39         'balance_start': fields.float('Opening Balance'),
40         'balance_end_real': fields.float('Closing Balance'),
41     }
42     _order = 'date desc'
43
44     def init(self, cr):
45         tools.drop_view_if_exists(cr, 'report_cash_register')
46         cr.execute("""
47             create or replace view report_cash_register as (
48                 select
49                     min(s.id) as id,
50                     to_date(to_char(s.create_date, 'dd-MM-YYYY'),'dd-MM-YYYY') as date,
51                     s.user_id as user_id,
52                     s.journal_id as journal_id,
53                     s.state as state,
54                     s.balance_start as balance_start,
55                     s.balance_end_real as balance_end_real,
56                     to_char(s.create_date, 'YYYY') as year,
57                     to_char(s.create_date, 'MM') as month,
58                     to_char(s.create_date, 'YYYY-MM-DD') as day
59                 from account_bank_statement as s where s.user_id=1
60                 group by
61                         s.user_id,s.journal_id, s.balance_start, s.balance_end_real,s.state,to_char(s.create_date, 'dd-MM-YYYY'),
62                         to_char(s.create_date, 'YYYY'),
63                         to_char(s.create_date, 'MM'),
64                         to_char(s.create_date, 'YYYY-MM-DD'))""")
65
66 report_cash_register()
67
68 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: