← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~therp-nl/ocb-addons/7.0_lp914670_update_picking_date into lp:ocb-addons

 

Ronald Portier (Therp) has proposed merging lp:~therp-nl/ocb-addons/7.0_lp914670_update_picking_date into lp:ocb-addons.

Requested reviews:
  OpenERP Community Backports (ocb)
Related bugs:
  Bug #914670 in OpenERP Community Backports (Addons): "[STOCK] 6.0 6.1 change move date don't update picking date"
  https://bugs.launchpad.net/ocb-addons/+bug/914670

For more details, see:
https://code.launchpad.net/~therp-nl/ocb-addons/7.0_lp914670_update_picking_date/+merge/223551

Fixes lp 914670. Expected date on stock.picking should change (be recomputed) when expected date on stock.move changes.
-- 
https://code.launchpad.net/~therp-nl/ocb-addons/7.0_lp914670_update_picking_date/+merge/223551
Your team OpenERP Community Backports is requested to review the proposed merge of lp:~therp-nl/ocb-addons/7.0_lp914670_update_picking_date into lp:ocb-addons.
=== modified file 'stock/stock.py'
--- stock/stock.py	2014-05-12 08:21:37 +0000
+++ stock/stock.py	2014-06-18 13:06:34 +0000
@@ -629,6 +629,18 @@
             res[pick]['min_date'] = dt1
             res[pick]['max_date'] = dt2
         return res
+    
+    def _get_stock_move_changes(self, cr, uid, ids, context=None):
+        '''Return the ids of pickings that should change, due to changes
+        in stock moves.'''
+        move_pool = self.pool['stock.move']
+        picking_ids = []
+        for move_obj in move_pool.browse(cr, uid, ids, context=context):
+            if move_obj.picking_id:
+                picking_id = move_obj.picking_id.id
+                if picking_id not in picking_ids:
+                    picking_ids.append(picking_id)
+        return picking_ids
 
     def create(self, cr, user, vals, context=None):
         if ('name' not in vals) or (vals.get('name')=='/'):
@@ -664,12 +676,31 @@
             * Transferred: has been processed, can't be modified or cancelled anymore\n
             * Cancelled: has been cancelled, can't be confirmed anymore"""
         ),
-        'min_date': fields.function(get_min_max_date, fnct_inv=_set_minimum_date, multi="min_max_date",
-                 store=True, type='datetime', string='Scheduled Time', select=1, help="Scheduled time for the shipment to be processed"),
+        'min_date': fields.function(
+            get_min_max_date,
+            fnct_inv=_set_minimum_date, multi='min_max_date',
+            store={
+                'stock.move': (
+                    _get_stock_move_changes,
+                    ['date_expected'], 10,
+                )
+            },
+            type='datetime', string='Scheduled Time', select=True,
+            help="Scheduled time for the shipment to be processed"
+        ),
         'date': fields.datetime('Creation Date', help="Creation date, usually the time of the order.", select=True, states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
         'date_done': fields.datetime('Date of Transfer', help="Date of Completion", states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),
-        'max_date': fields.function(get_min_max_date, fnct_inv=_set_maximum_date, multi="min_max_date",
-                 store=True, type='datetime', string='Max. Expected Date', select=2),
+        'max_date': fields.function(
+            get_min_max_date,
+            fnct_inv=_set_maximum_date, multi='min_max_date',
+            store={
+                'stock.move': (
+                    _get_stock_move_changes,
+                    ['date_expected'], 10,
+                )
+            },
+            type='datetime', string='Max. Expected Date', select=True
+        ),
         'move_lines': fields.one2many('stock.move', 'picking_id', 'Internal Moves', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}),
         'product_id': fields.related('move_lines', 'product_id', type='many2one', relation='product.product', string='Product'),
         'auto_picking': fields.boolean('Auto-Picking', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}),


Follow ups