From 35a061eb0d3409c50aba6fb88af6c642030544d5 Mon Sep 17 00:00:00 2001 From: Nicolas Seinlet Date: Tue, 13 Jan 2015 16:32:45 +0100 Subject: [PATCH] [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. --- addons/point_of_sale/point_of_sale.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 03c622127f1..1e2af6bd5a5 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -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):