[IMP] point_of_sale: faster loading of pos session

name_get of pos.category should use a browse instead of a read.
For a company having thousands of products and a few categories, using a browse
will greatly improve the load time as it is cached.
This commit is contained in:
Nicolas Seinlet 2015-01-13 16:32:45 +01:00 committed by Martin Trigaux
parent ccb4e4332e
commit 35a061eb0d
1 changed files with 6 additions and 5 deletions

View File

@ -1354,13 +1354,14 @@ class pos_category(osv.osv):
def name_get(self, cr, uid, ids, context=None):
if not len(ids):
return []
reads = self.read(cr, uid, ids, ['name','parent_id'], context=context)
reads = self.browse(cr, uid, ids, context=context)
res = []
for record in reads:
name = record['name']
if record['parent_id']:
name = record['parent_id'][1]+' / '+name
res.append((record['id'], name))
if record.parent_id:
name = '%s / %s' % (record.parent_id.name, record.name)
else:
name = record.name
res.append((record.id, name))
return res
def _name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):