=== modified file 'bin/addons/base/res/country.py'
--- bin/addons/base/res/country.py 2010-04-30 09:42:24 +0000
+++ bin/addons/base/res/country.py 2010-09-11 17:03:48 +0000
@@ -31,6 +31,8 @@
'code': fields.char('Country Code', size=2,
help='The ISO country code in two chars.\n'
'You can use this field for quick search.', required=True),
+ 'zip_position' : fields.selection([('before','Before'),('after','After'),('below','Below')],
+ string='Zip Position', help="Defines if the zip is positioned before or after or below the city"),
}
_sql_constraints = [
('name_uniq', 'unique (name)',
=== modified file 'bin/addons/base/res/country_view.xml'
--- bin/addons/base/res/country_view.xml 2010-07-28 13:31:20 +0000
+++ bin/addons/base/res/country_view.xml 2010-09-11 16:50:08 +0000
@@ -14,6 +14,7 @@
+
@@ -26,6 +27,7 @@
=== modified file 'bin/addons/base/res/partner/partner.py'
--- bin/addons/base/res/partner/partner.py 2010-09-08 12:24:00 +0000
+++ bin/addons/base/res/partner/partner.py 2010-09-11 17:28:08 +0000
@@ -265,6 +265,60 @@
class res_partner_address(osv.osv):
_description ='Partner Addresses'
_name = 'res.partner.address'
+
+ def _address_label(self, cr, uid, ids, name, arg, context=None):
+ res = {}
+ lf ='\x0A'
+ for a in self.browse(cr, uid, ids, context=context):
+ l = a.partner_id.name
+ if a.partner_id.title:
+ l = l + ' ' + a.partner_id.title.name
+ t = ''
+ if a.title:
+ t = a.title.name + ' ' or ''
+ if a.name:
+ t = t + a.name
+ if t:
+ l = l + lf + t
+ if a.street:
+ l = l + lf + a.street
+ if a.street2:
+ l = l + lf + a.street2
+ z = ''
+ if a.city:
+ z = a.city
+ if a.zip:
+ zip_position=''
+ if a.country_id.zip_position:
+ zip_position = a.country_id.zip_position
+ if not zip_position:
+ zip_position='before'
+ if a.company_id and a.company_id.partner_id and a.company_id.partner_id.address:
+ for ca in a.company_id.partner_id.address:
+ if ca.country_id and ca.country_id.zip_position:
+ zip_position = ca.country_id.zip_position
+ break
+ else:
+ zip_position='before'
+ # FIXME - where else can we get a unique default country ?
+ #res_users_obj = self.pool.get('res.users')
+ #if res_users_obj.company_id.partner_id.address_ids:
+
+ if zip_position == 'before':
+ z = a.zip + ' ' + z
+ if zip_position == 'after':
+ z = z + ' ' + a.zip
+ if zip_position == 'below':
+ z = z + lf + a.zip
+ if z:
+ l = l +lf + z
+ if a.state_id:
+ l = l + lf + a.state_id.name
+ if a.country_id:
+ l = l + lf + a.country_id.name
+ res[a.id] = l
+ return res
+
_columns = {
'partner_id': fields.many2one('res.partner', 'Partner Name', ondelete='set null', select=True, help="Keep empty for a private address, not related to partner."),
'type': fields.selection( [ ('default','Default'),('invoice','Invoice'), ('delivery','Delivery'), ('contact','Contact'), ('other','Other') ],'Address Type', help="Used to select automatically the right address according to the context in sales and purchases documents."),
@@ -287,6 +341,7 @@
'active': fields.boolean('Active', help="Uncheck the active field to hide the contact."),
# 'company_id': fields.related('partner_id','company_id',type='many2one',relation='res.company',string='Company', store=True),
'company_id': fields.many2one('res.company', 'Company',select=1),
+ 'address_label' : fields.function(_address_label, method = True, type='text', string="Address Label"),
}
_defaults = {
'active': lambda *a: 1,
=== modified file 'bin/addons/base/res/partner/partner_view.xml'
--- bin/addons/base/res/partner/partner_view.xml 2010-08-20 06:44:30 +0000
+++ bin/addons/base/res/partner/partner_view.xml 2010-09-11 16:06:44 +0000
@@ -92,6 +92,7 @@
+