435.1.1
by Julio Serna
[IMP][res_address_code] added module res_address_code |
1 |
# -*- encoding: utf-8 -*-
|
2 |
###########################################################################
|
|
3 |
# Module Writen to OpenERP, Open Source Management Solution
|
|
4 |
#
|
|
5 |
# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
|
|
6 |
# All Rights Reserved.
|
|
7 |
# info@vauxoo.com
|
|
8 |
############################################################################
|
|
9 |
# Coded by: julio (julio@vauxoo.com)
|
|
10 |
############################################################################
|
|
11 |
#
|
|
12 |
# This program is free software: you can redistribute it and/or modify
|
|
13 |
# it under the terms of the GNU Affero General Public License as
|
|
14 |
# published by the Free Software Foundation, either version 3 of the
|
|
15 |
# License, or (at your option) any later version.
|
|
16 |
#
|
|
17 |
# This program is distributed in the hope that it will be useful,
|
|
18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 |
# GNU Affero General Public License for more details.
|
|
21 |
#
|
|
22 |
# You should have received a copy of the GNU Affero General Public License
|
|
23 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24 |
#
|
|
25 |
##############################################################################
|
|
26 |
||
542.1.189
by Julio Serna
[V7-MIGRATION] |
27 |
from openerp.osv import osv, fields |
28 |
||
29 |
||
30 |
class res_partner_address(osv.Model): |
|
435.1.1
by Julio Serna
[IMP][res_address_code] added module res_address_code |
31 |
_inherit = 'res.partner.address' |
32 |
_columns = { |
|
542.1.188
by Julio Serna
[AUTOPEP8] |
33 |
'code': fields.char('Code', size=64, help='En caso de que la dirección sea de una sucursal, se puede agregar el código de ésta.') |
435.1.1
by Julio Serna
[IMP][res_address_code] added module res_address_code |
34 |
}
|
542.1.188
by Julio Serna
[AUTOPEP8] |
35 |
|
435.1.1
by Julio Serna
[IMP][res_address_code] added module res_address_code |
36 |
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): |
37 |
ids = [] |
|
38 |
if not args: |
|
39 |
args = [] |
|
40 |
if name: |
|
542.1.188
by Julio Serna
[AUTOPEP8] |
41 |
ids = self.search(cr, user, [( |
42 |
'code', '=', name)] + args, limit=limit, context=context) |
|
435.1.1
by Julio Serna
[IMP][res_address_code] added module res_address_code |
43 |
if not ids: |
542.1.188
by Julio Serna
[AUTOPEP8] |
44 |
ids = self.search(cr, user, [( |
45 |
'code', operator, name)] + args, limit=limit, context=context) |
|
46 |
ids += map(lambda a: a[0], super(res_partner_address, self).name_search( |
|
47 |
cr, user, name=name, args=args, operator=operator, context=context, limit=limit)) |
|
435.1.1
by Julio Serna
[IMP][res_address_code] added module res_address_code |
48 |
ids = set(ids) |
49 |
ids = list(ids) |
|
50 |
result = self.name_get(cr, user, ids, context=context) |
|
51 |
return result |