|
@ -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) |