From 2be02b09666bf63d243471c6d32e666d08b3602a Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Wed, 22 Jan 2014 17:33:51 +0100 Subject: [PATCH] [FIX]order stock_inventory_line by location name, product code, product name lp bug: https://launchpad.net/bugs/1087033 fixed bzr revid: csn@openerp.com-20140122163351-c6si7b339inpq5gi --- addons/stock/stock.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 91feb16bca5..339d8335997 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2197,6 +2197,14 @@ class stock_inventory_line(osv.osv): _name = "stock.inventory.line" _description = "Inventory Line" _rec_name = "inventory_id" + _order = "location_name, product_code, product_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) + _columns = { 'inventory_id': fields.many2one('stock.inventory', 'Inventory', ondelete='cascade', select=True), 'location_id': fields.many2one('stock.location', 'Location', required=True, select=True), @@ -2209,6 +2217,15 @@ class stock_inventory_line(osv.osv): 'state': fields.related('inventory_id', 'state', type='char', string='Status', readonly=True), 'th_qty': fields.float('Theoretical Quantity', readonly=True), 'partner_id': fields.many2one('res.partner', 'Owner'), + 'product_name': fields.related('product_id', 'name', type='char', string='Product name', store={ + 'product.product': (_get_product_name_change, ['name', 'default_code'], 20), + 'stock.inventory.line': (lambda self, cr, uid, ids, c={}: ids, ['product_id'], 20),}), + 'product_code': fields.related('product_id', 'default_code', type='char', string='Product code', store={ + 'product.product': (_get_product_name_change, ['name', 'default_code'], 20), + 'stock.inventory.line': (lambda self, cr, uid, ids, c={}: ids, ['product_id'], 20),}), + '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),}), } _defaults = {