~vauxoo/addons-vauxoo/8.0-import_tax_tariff-dev-yani-rev-2

« back to all changes in this revision

Viewing changes to stock_location_code/stock.py

  • Committer: Nhomar Hernandez
  • Date: 2013-04-19 20:33:12 UTC
  • mfrom: (542.1.314 addons-vauxoo)
  • Revision ID: nhomar@gmail.com-20130419203312-o35v7dn79l6vur0t
[MERGE - PEP8 AND V7-MIG] All migrated to V7 Just
improved osv.osv => osv.Model, osv.osv_memory => osv.TransientModel
import inside openerp.* enviroment
Erased class instansiation no necesarry anymore in V7
AUTOPEP8 run, Left PEP8 long lines manually.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#
25
25
##############################################################################
26
26
 
27
 
from osv import osv, fields
 
27
from openerp.osv import osv, fields
28
28
import re
29
29
 
30
 
class stock_location(osv.osv):
 
30
 
 
31
class stock_location(osv.Model):
31
32
    _inherit = 'stock.location'
32
33
    _columns = {
33
 
        'code' : fields.char('Code', size=64)
 
34
        'code': fields.char('Code', size=64)
34
35
    }
35
 
    
 
36
 
36
37
    def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
37
38
        if not args:
38
39
            args = []
39
40
        if name:
40
 
            ids = self.search(cr, user, [('code','=',name)]+ args, limit=limit, context=context)
 
41
            ids = self.search(cr, user, [(
 
42
                'code', '=', name)] + args, limit=limit, context=context)
41
43
            if not ids:
42
44
                ids = set()
43
 
                ids.update(self.search(cr, user, args + [('code',operator,name)], limit=limit, context=context))
44
 
                ids.update(map(lambda a: a[0], super(stock_location, self).name_search(cr, user, name=name, args=args, operator=operator, context=context, limit=limit)))
 
45
                ids.update(self.search(cr, user, args + [(
 
46
                    'code', operator, name)], limit=limit, context=context))
 
47
                ids.update(map(lambda a: a[0], super(stock_location, self).name_search(
 
48
                    cr, user, name=name, args=args, operator=operator, context=context, limit=limit)))
45
49
                ids = list(ids)
46
50
        else:
47
51
            ids = self.search(cr, user, args, limit=limit, context=context)
48
52
        result = self.name_get(cr, user, ids, context=context)
49
53
        return result
50
 
stock_location()