[FIX] Schedule jobs even if their next time has passed.
[odoo/odoo.git] / addons / l10n_ch / bank.py
1 # -*- encoding: utf-8 -*-
2 #  bank.py
3 #  l10n_ch
4 #
5 #  Created by Nicolas Bessi based on Credric Krier contribution
6 #
7 #  Copyright (c) 2010 CamptoCamp. All rights reserved.
8 ##############################################################################
9 # WARNING: This program as such is intended to be used by professional
10 # programmers who take the whole responsability of assessing all potential
11 # consequences resulting from its eventual inadequacies and bugs
12 # End users who are looking for a ready-to-use solution with commercial
13 # garantees and support are strongly adviced to contract a Free Software
14 # Service Company
15 #
16 # This program is Free Software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation; either version 2
19 # of the License, or (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29 #
30 ##############################################################################
31
32 from osv import fields, osv
33
34
35 class Bank(osv.osv):
36     """Inherit res.bank class in order to add swiss specific field"""
37     _inherit = 'res.bank'
38     _columns = {
39         ### Swiss unik bank identifier also use in IBAN number
40         'clearing': fields.char('Clearing number', size=64),
41         ### City of the bank
42         'city': fields.char('City', size=128, select=1),
43     }
44
45 Bank()
46
47
48 class ResPartnerBank(osv.osv):
49     """Override of res.partner.bank"""
50     
51     _inherit = "res.partner.bank"
52     _columns = {
53         ## Account number
54         'acc_number': fields.char(
55                                     'Account Number', 
56                                     size=64, 
57                                     required=False,
58                                     help='Bank account number'
59                                     ),
60         ## Account name
61         'name': fields.char(
62                                 'Description', 
63                                 size=128, 
64                                 required=True,
65                             ),
66         ## Post account code to be redesing
67         'post_number': fields.char(
68                                     'Post number', 
69                                     size=64,
70                                     help='CCP, postal account number used for '+
71                                     'postal payment format xx-xxxx-x'
72                                     ),
73         ## Post account code to be redesing
74         'bvr_number': fields.char(
75                                     'BVR account number', 
76                                     size=11,
77                                     help='Postal account number of the '+ 
78                                     'financial establishment.'+
79                                     'Used foe BV bank payment '+
80                                     'format xx-xxxxx-x'
81                                     
82                                 ),
83         ## Post financne affiliation number
84         'bvr_adherent_num': fields.char(
85                                         'BVR adherent number', 
86                                          size=11,
87                                          help='PostFinance affiliation BVR number '+
88                                          'of your financial establishement'+
89                                          'used for BVR/ESR printing'
90                                         ),
91         ## DTA code used by Mammuth
92         'dta_code': fields.char(
93                                 'DTA code', 
94                                 size=5,
95                                 help='Code used by transfer system for '+
96                                 'identify the bank. Ex Mammuth'
97                                 ),
98         ### Will print the Bank name on BVR/ESR
99         'printbank' : fields.boolean(
100                                 'Print Bank on BVR',
101                                 help='will print bank name on the ESR/BVR'
102                                     ),
103         ### Will print the Bank account on BVR/ESR
104         'printaccount' : fields.boolean(
105                                         'Print Account Number on BVR',
106                                         help='will print bank account'+
107                                         'name on the ESR/BVR'
108                                         ),
109     }
110         
111     def name_get(self, cursor, uid, ids, context=None):
112         """Override of the name get function of the bank 
113         in order to have the partner link to the bank"""
114         if not len(ids):
115             return []
116         bank_type_obj = self.pool.get('res.partner.bank.type')
117
118         type_ids = bank_type_obj.search(cursor, uid, [])
119         bank_type_names = {}
120         for bank_type in bank_type_obj.browse(cursor, uid, type_ids,
121                 context=context):
122             bank_type_names[bank_type.code] = bank_type.name
123         res = []
124         for bank in self.read(cursor, uid, ids, ['name', 'state'], context):
125             res.append((bank['id'], bank['name']+
126                 ' : '+bank_type_names[bank['state']]))
127         return res
128     
129     _sql_constraints = [
130         ('bvr_adherent_uniq', 'unique (bvr_adherent_num)', 
131             'The BVR adherent number must be unique !')
132     ]
133 ResPartnerBank()