← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~numerigraphe-team/ocb-addons/7.0-inventory-lines-sorted into lp:ocb-addons

 

Lionel Sausin - Numérigraphe has proposed merging lp:~numerigraphe-team/ocb-addons/7.0-inventory-lines-sorted into lp:ocb-addons.

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1087033 in OpenERP Community Backports (Addons): "Inventory lines should be sorted on screen and print documents"
  https://bugs.launchpad.net/ocb-addons/+bug/1087033

For more details, see:
https://code.launchpad.net/~numerigraphe-team/ocb-addons/7.0-inventory-lines-sorted/+merge/210467

This branch makes the inventory lines sorted on location name, product name and serial number.
It greatly eases the work of inventory workers when counting big inventories.
This solution is backported from trunk-wms (future v8), with an additionnal improvement to sort on serial numbers' names instead of their IDs.

-- 
https://code.launchpad.net/~numerigraphe-team/ocb-addons/7.0-inventory-lines-sorted/+merge/210467
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~numerigraphe-team/ocb-addons/7.0-inventory-lines-sorted into lp:ocb-addons.
=== modified file 'stock/stock.py'
--- stock/stock.py	2014-03-04 13:08:40 +0000
+++ stock/stock.py	2014-03-11 18:17:12 +0000
@@ -2954,6 +2954,17 @@
     _name = "stock.inventory.line"
     _description = "Inventory Line"
     _rec_name = "inventory_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),
         'location_id': fields.many2one('stock.location', 'Location', required=True),
@@ -2963,6 +2974,18 @@
         'company_id': fields.related('inventory_id','company_id',type='many2one',relation='res.company',string='Company',store=True, select=True, readonly=True),
         'prod_lot_id': fields.many2one('stock.production.lot', 'Serial Number', domain="[('product_id','=',product_id)]"),
         'state': fields.related('inventory_id','state',type='char',string='Status',readonly=True),
+        '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),}),
+        '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):


Follow ups