Please review this at http://codereview.appspot.com/1850051/show
Affected files: M INSTALL M address.py Index: INSTALL =================================================================== --- a/INSTALL +++ b/INSTALL @@ -4,7 +4,7 @@ Prerequisites ------------- - * Python 2.4 or later (http://www.python.org/) + * Python 2.5 or later (http://www.python.org/) * trytond (http://www.tryton.org/) * trytond_party (http://www.tryton.org/) Index: address.py =================================================================== --- a/address.py +++ b/address.py @@ -1,7 +1,9 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. +import urllib from trytond.model import ModelView, ModelSQL, fields -import urllib +from trytond.transaction import Transaction + class Address(ModelSQL, ModelView): _name = 'party.address' @@ -10,10 +12,8 @@ on_change_with=['street', 'streetbis', 'zip', 'city', 'country', 'subdivision']), 'get_google_maps_url') - def _get_url(self, cursor, user, vals, context=None): - if context is None: - context = {} - lang = context.get('language', 'en_US')[:2] + def _get_url(self, vals): + lang = Transaction().language[:2] url = '' for i in ['street', 'streetbis', 'zip', 'city', 'country', 'subdivision']: @@ -29,28 +29,25 @@ url = '' return url - def on_change_with_google_maps_url(self, cursor, user, vals, - context=None): + def on_change_with_google_maps_url(self, vals): country_obj = self.pool.get('country.country') subdivision_obj = self.pool.get('country.subdivision') vals = vals.copy() if vals.get('country'): - country = country_obj.browse(cursor, user, vals['country'], - context=context) + country = country_obj.browse(vals['country']) vals['country'] = country.name if vals.get('subdivision'): - subdivision = subdivision_obj.browse(cursor, user, - vals['subdivision'], context=context) + subdivision = subdivision_obj.browse(vals['subdivision']) vals['subdivision'] = subdivision.name - return self._get_url(cursor, user, vals, context=context) + return self._get_url(vals) - def get_google_maps_url(self, cursor, user, ids, name, context=None): + def get_google_maps_url(self, ids, name): res = {} - for address in self.browse(cursor, user, ids, context=context): + for address in self.browse(ids): vals = { 'street': address.street, 'streetbis': address.streetbis, @@ -60,8 +57,7 @@ 'subdivision': address.subdivision and \ address.subdivision.name or False, } - res[address.id] = self._get_url(cursor, user, vals, - context=context) + res[address.id] = self._get_url(vals) return res Address() -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4 4000 Liège Belgium Tel: +32 472 54 46 59 Email/Jabber: [email protected] Website: http://www.b2ck.com/
pgpayVcK2GHwD.pgp
Description: PGP signature
