1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6
# Copyright (C) 2010-2010 Camptocamp Austria (<http://www.camptocamp.at>)
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.
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.
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/>.
21
##############################################################################
23
from osv import fields,osv
26
from tools.translate import _
28
#----------------------------------------------------------
30
#----------------------------------------------------------
32
class Country(osv.osv):
33
_inherit = 'res.country'
35
'zip_position' : fields.selection([('before','Before'),('after','After'),('below','Below')], string="Zip Position", help="Zip position relative to city name"),
39
'zip_position': lambda *a: 'before',
43
# set reasonable values
44
cr.execute("""update res_country
45
set zip_position = 'after'
47
and zip_position is null""")
48
cr.execute("""update res_country
49
set zip_position = 'below'
51
and zip_position is null""")
54
#----------------------------------------------------------
56
#----------------------------------------------------------
58
class res_company(osv.osv):
59
_inherit = 'res.company'
61
'address_label_position' : fields.selection([('left','Left'),('rigth','Right')], string="Address Window Position", help="Position of address window on standard company enevlops. Many reports do not use this yet"),
64
'address_label_position': lambda *a: 'right',
69
#----------------------------------------------------------
71
#----------------------------------------------------------
72
class res_partner_address(osv.osv):
73
_inherit = 'res.partner.address'
75
def _address_label(self, cr, uid, ids, name, arg, context=None):
79
for a in self.browse(cr, uid, ids, context=context):
80
l = a.partner_id.name or ''
81
if a.partner_id.title:
82
l = l + ' ' + a.partner_id.title.name
85
t = a.title.name + ' ' or ''
93
l = l + lf + a.street2
99
if a.country_id.zip_position:
100
zip_position = a.country_id.zip_position
101
if zip_position == 'before':
103
if zip_position == 'after':
105
z = z + ', ' + a.state_id.code +', '+ a.zip
108
if zip_position == 'below':
113
l = l + lf + a.state_id.name
115
l = l + lf + a.country_id.name
121
'address_label': fields.function(_address_label, type='text', method = True, string="Address Label"),
124
res_partner_address()