Browse Source

[FIX] base_location PEP8

pull/14/head
Lorenzo Battistini 10 years ago
parent
commit
65603ccbc1
  1. 19
      base_location/better_zip.py
  2. 26
      base_location/company.py
  3. 20
      base_location/partner.py
  4. 7
      base_location/state.py

19
base_location/better_zip.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# #
# Author: Nicolas Bessi. Copyright Camptocamp SA # Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com> # Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
@ -18,11 +18,12 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
##############################################################################
#
from openerp.osv import orm, fields from openerp.osv import orm, fields
class BetterZip(orm.Model): class BetterZip(orm.Model):
" City/locations completion object" " City/locations completion object"
_name = "res.better.zip" _name = "res.better.zip"
@ -57,19 +58,25 @@ class BetterZip(orm.Model):
def onchange_state_id(self, cr, uid, ids, state_id=False, context=None): def onchange_state_id(self, cr, uid, ids, state_id=False, context=None):
result = {} result = {}
if state_id: if state_id:
state = self.pool['res.country.state'].browse(cr, uid, state_id, context=context)
state = self.pool['res.country.state'].browse(
cr, uid, state_id, context=context)
if state: if state:
result['value'] = {'country_id': state.country_id.id} result['value'] = {'country_id': state.country_id.id}
return result return result
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
def name_search(
self, cr, uid, name, args=None, operator='ilike', context=None,
limit=100
):
if args is None: if args is None:
args = [] args = []
if context is None: if context is None:
context = {} context = {}
ids = [] ids = []
if name: if name:
ids = self.search(cr, uid, [('name', 'ilike', name)] + args, limit=limit)
ids = self.search(
cr, uid, [('name', 'ilike', name)] + args, limit=limit)
if not ids: if not ids:
ids = self.search(cr, uid, [('city', operator, name)] + args, limit=limit)
ids = self.search(
cr, uid, [('city', operator, name)] + args, limit=limit)
return self.name_get(cr, uid, ids, context=context) return self.name_get(cr, uid, ids, context=context)

26
base_location/company.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# #
# Author: Nicolas Bessi. Copyright Camptocamp SA # Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com> # Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
@ -18,7 +18,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
##############################################################################
#
from openerp.osv import orm, fields from openerp.osv import orm, fields
@ -31,17 +31,19 @@ class ResCompany(orm.Model):
if context is None: if context is None:
context = {} context = {}
if zip_id: if zip_id:
bzip = self.pool['res.better.zip'].browse(cr, uid, zip_id, context=context)
result = {'value': {'zip': bzip.name,
'country_id': bzip.country_id.id if bzip.country_id else False,
'city': bzip.city,
'state_id': bzip.state_id.id if bzip.state_id else False
}
}
bzip = self.pool['res.better.zip'].browse(
cr, uid, zip_id, context=context)
result = {'value': {
'zip': bzip.name,
'country_id': bzip.country_id.id if bzip.country_id else False,
'city': bzip.city,
'state_id': bzip.state_id.id if bzip.state_id else False
}
}
return result return result
_columns = { _columns = {
'better_zip_id': fields.many2one('res.better.zip', 'Location', select=1,
help=('Use the city name or the zip code'
' to search the location')),
'better_zip_id': fields.many2one(
'res.better.zip', 'Location', select=1,
help=('Use the city name or the zip code to search the location')),
} }

20
base_location/partner.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# #
# Author: Nicolas Bessi. Copyright Camptocamp SA # Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com> # Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
@ -18,7 +18,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
##############################################################################
#
from openerp.osv import orm, fields from openerp.osv import orm, fields
@ -31,10 +31,12 @@ class ResPartner(orm.Model):
return {} return {}
if isinstance(zip_id, list): if isinstance(zip_id, list):
zip_id = zip_id[0] zip_id = zip_id[0]
bzip = self.pool['res.better.zip'].browse(cursor, uid, zip_id, context=context)
return {'value': {'zip': bzip.name,
'city': bzip.city,
'country_id': bzip.country_id.id if bzip.country_id else False,
'state_id': bzip.state_id.id if bzip.state_id else False,
}
}
bzip = self.pool['res.better.zip'].browse(
cursor, uid, zip_id, context=context)
return {'value': {
'zip': bzip.name,
'city': bzip.city,
'country_id': bzip.country_id.id if bzip.country_id else False,
'state_id': bzip.state_id.id if bzip.state_id else False,
}
}

7
base_location/state.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
#
# #
# Author: Nicolas Bessi. Copyright Camptocamp SA # Author: Nicolas Bessi. Copyright Camptocamp SA
# Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com> # Contributor: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>
@ -18,7 +18,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
##############################################################################
#
from openerp.osv import orm, fields from openerp.osv import orm, fields
@ -26,4 +26,5 @@ class ResCountryState(orm.Model):
_inherit = 'res.country.state' _inherit = 'res.country.state'
_columns = {'better_zip_ids': fields.one2many('res.better.zip', 'state_id', 'Cities')}
_columns = {'better_zip_ids': fields.one2many(
'res.better.zip', 'state_id', 'Cities')}
Loading…
Cancel
Save