[FIX] stock: Scheduled / Max. Expected date change on picking when changed in its moves
When changing the min_date / max_date in a move, the date change wasn't propagated to its picking. The use of store triggers is needed in such a case, `store=True` isn't enough Fixes #1862 Closes #3278
This commit is contained in:
parent
b541187345
commit
607114ff00
|
@ -630,6 +630,13 @@ class stock_picking(osv.osv):
|
|||
res[pick]['max_date'] = dt2
|
||||
return res
|
||||
|
||||
def _get_pickings(self, cr, uid, ids, context=None):
|
||||
res = set()
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.picking_id and not move.picking_id.min_date < move.date_expected < move.picking_id.max_date:
|
||||
res.add(move.picking_id.id)
|
||||
return list(res)
|
||||
|
||||
def create(self, cr, user, vals, context=None):
|
||||
if ('name' not in vals) or (vals.get('name')=='/'):
|
||||
seq_obj_name = self._name
|
||||
|
@ -665,11 +672,11 @@ class stock_picking(osv.osv):
|
|||
* 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"),
|
||||
store={'stock.move': (_get_pickings, ['date_expected', 'picking_id'], 20)}, type='datetime', string='Scheduled Time', select=1, 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),
|
||||
store={'stock.move': (_get_pickings, ['date_expected', 'picking_id'], 20)}, type='datetime', string='Max. Expected Date', select=2),
|
||||
'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)]}),
|
||||
|
|
Loading…
Reference in New Issue