From 0b5ca307d5c9a550bb8c2919ae53206fc94018da Mon Sep 17 00:00:00 2001 From: Lionel Sausin Date: Tue, 11 Mar 2014 19:12:36 +0100 Subject: [PATCH] [IMP] sort inventory lines on the name of serial numbers, not their ID bzr revid: ls@numerigraphe.com-20140311181236-o0pnweb0ze1efdwy --- addons/stock/stock.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index e34fcb1adbe..5cc0af224b9 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2867,13 +2867,16 @@ class stock_inventory_line(osv.osv): _name = "stock.inventory.line" _description = "Inventory Line" _rec_name = "inventory_id" - _order = "inventory_id, location_name, product_code, product_name, prod_lot_id" + _order = "inventory_id, location_name, product_code, product_name, prodlot_name" def _get_product_name_change(self, cr, uid, ids, context=None): return self.pool.get('stock.inventory.line').search(cr, uid, [('product_id', 'in', ids)], context=context) def _get_location_change(self, cr, uid, ids, context=None): return self.pool.get('stock.inventory.line').search(cr, uid, [('location_id', 'in', ids)], context=context) + + def _get_prodlot_change(self, cr, uid, ids, context=None): + return self.pool.get('stock.inventory.line').search(cr, uid, [('prod_lot_id', 'in', ids)], context=context) _columns = { 'inventory_id': fields.many2one('stock.inventory', 'Inventory', ondelete='cascade', select=True), @@ -2893,6 +2896,9 @@ class stock_inventory_line(osv.osv): 'location_name': fields.related('location_id', 'complete_name', type='char', string='Location name', store={ 'stock.location': (_get_location_change, ['name', 'location_id', 'active'], 20), 'stock.inventory.line': (lambda self, cr, uid, ids, c={}: ids, ['location_id'], 20),}), + 'prodlot_name': fields.related('prod_lot_id', 'name', type='char', string='Serial Number name', store={ + 'stock.production.lot': (_get_prodlot_change, ['name'], 20), + 'stock.inventory.line': (lambda self, cr, uid, ids, c={}: ids, ['prod_lot_id'], 20),}), } def _default_stock_location(self, cr, uid, context=None):