[FIX] mrp : Corrections for Work Order names
[odoo/odoo.git] / addons / l10n_ch / partner.py
1 # -*- coding: utf-8 -*-
2 #
3 #  bank.py
4 #  partner.py
5 #
6 #  Created by Nicolas Bessi based on Credric Krier contribution
7 #
8 #  Copyright (c) 2009 CamptoCamp. All rights reserved.
9 ##############################################################################
10 # WARNING: This program as such is intended to be used by professional
11 # programmers who take the whole responsability of assessing all potential
12 # consequences resulting from its eventual inadequacies and bugs
13 # End users who are looking for a ready-to-use solution with commercial
14 # garantees and support are strongly adviced to contract a Free Software
15 # Service Company
16 #
17 # This program is Free Software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License
19 # as published by the Free Software Foundation; either version 2
20 # of the License, or (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
30 #
31 ##############################################################################
32
33 from osv import fields, osv
34
35 class res_partner(osv.osv):
36     _inherit = 'res.partner'
37
38     _columns = {
39         'ref_companies': fields.one2many('res.company', 'partner_id',
40         'Companies that refers to partner'),
41     }
42
43 res_partner()
44
45 class res_partner_bank(osv.osv):
46     _inherit = "res.partner.bank"
47     _columns = {
48         'name': fields.char('Description', size=128, required=True),
49         'post_number': fields.char('Post number', size=64),
50         'bvr_number': fields.char('BVR account number', size=11),
51         'bvr_adherent_num': fields.char('BVR adherent number', size=11),
52         'dta_code': fields.char('DTA code', size=5),
53     }
54
55     def name_get(self, cr, uid, ids, context=None):
56         if not len(ids):
57             return []
58         bank_type_obj = self.pool.get('res.partner.bank.type')
59
60         type_ids = bank_type_obj.search(cr, uid, [])
61         bank_type_names = {}
62         for bank_type in bank_type_obj.browse(cr, uid, type_ids,
63                 context=context):
64             bank_type_names[bank_type.code] = bank_type.name
65         res = []
66         for r in self.read(cr, uid, ids, ['name','state'], context):
67             res.append((r['id'], r['name']+' : '+bank_type_names[r['state']]))
68         return res
69
70     _sql_constraints = [
71         ('bvr_adherent_uniq', 'unique (bvr_adherent_num)', 'The BVR adherent number must be unique !')
72     ]
73
74 res_partner_bank()
75
76 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: