Skip to content

Commit

Permalink
[FIX] stock: Expected date on stock.picking will change, if Expected …
Browse files Browse the repository at this point in the history
…date on stock.move changes. This fixes bug lp1266480.

https://launchpad.net/bugs/914670
  • Loading branch information
NL66278 authored and Stefan Rijnhart committed Jul 2, 2014
1 parent c2882f4 commit d90d208
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions addons/stock/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,16 @@ def get_min_max_date(self, cr, uid, ids, field_name, arg, context=None):
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 = set()
for move_obj in move_pool.browse(cr, uid, ids, context=context):
if move_obj.picking_id:
picking_ids.add(move_obj.picking_id.id)
return list(picking_ids)

def create(self, cr, user, vals, context=None):
if ('name' not in vals) or (vals.get('name')=='/'):
Expand Down Expand Up @@ -664,12 +674,31 @@ def create(self, cr, user, vals, context=None):
* 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)]}),
Expand Down

0 comments on commit d90d208

Please sign in to comment.