Launchpad automatic translations update.
[odoo/odoo.git] / addons / point_of_sale / account_bank_statement.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2008 PC Solutions (<http://pcsol.be>). All Rights Reserved
6 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 #
8 #    This program is free software: you can redistribute it and/or modify
9 #    it under the terms of the GNU Affero General Public License as
10 #    published by the Free Software Foundation, either version 3 of the
11 #    License, or (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 Affero General Public License for more details.
17 #
18 #    You should have received a copy of the GNU Affero 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 account_journal(osv.osv):
26     _inherit = 'account.journal'
27     _columns = {
28         'auto_cash': fields.boolean('Automatic Opening', help="This field authorize the automatic creation of the cashbox"),
29         'special_journal': fields.boolean('Special Journal', help="Will put all the orders in waiting status till being accepted"),
30         'check_dtls': fields.boolean('Check Details', help="This field authorize Validation of Cashbox without checking ending details"),
31         'journal_users': fields.many2many('res.users', 'pos_journal_users', 'journal_id', 'user_id', 'Users'),
32     }
33     _defaults = {
34         'check_dtls': False,
35         'auto_cash': True,
36     }
37
38 account_journal()
39
40 class account_cash_statement(osv.osv):
41     _inherit = 'account.bank.statement'
42
43     def _equal_balance(self, cr, uid, cash_id, context=None):
44         if context is None:
45             context = {}
46         statement = self.browse(cr, uid, cash_id, context=context)
47         if not statement.journal_id.check_dtls:
48             return True
49         if statement.journal_id.check_dtls and (statement.balance_end != statement.balance_end_cash):
50             return False
51         else:
52             return True
53
54     def _user_allow(self, cr, uid, statement_id, context=None):
55         statement = self.browse(cr, uid, statement_id, context=context)
56         if (not statement.journal_id.journal_users) and uid == 1: return True
57         for user in statement.journal_id.journal_users:
58             if uid == user.id:
59                 return True
60         return False
61
62     def _get_cash_open_box_lines(self, cr, uid, context=None):
63         if context is None:
64             context = {}
65         res = super(account_cash_statement,self)._get_cash_open_box_lines(cr, uid, context)
66         curr = [0.01, 0.02, 0.05, 0.10, 0.20, 0.50]
67         for rs in curr:
68             dct = {
69                 'pieces': rs,
70                 'number': 0
71             }
72             res.append(dct)
73         res.sort()
74         return res
75
76     def _get_default_cash_close_box_lines(self, cr, uid, context=None):
77         if context is None:
78             context = {}
79         res = super(account_cash_statement,self)._get_default_cash_close_box_lines(cr, uid, context=context)
80         curr = [0.01, 0.02, 0.05, 0.10, 0.20, 0.50]
81         for rs in curr:
82             dct = {
83                 'pieces': rs,
84                 'number': 0
85             }
86             res.append(dct)
87         res.sort()
88         return res
89
90 account_cash_statement()
91
92 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: