[FIX] delivery: reset delivery info on duplicate/backorder
The tracking reference and other delivery references are not relevant to duplicated pickings. Overwrite copy to remove carrier_tracking_ref, volume and number_of_packages. Add fallback on stock.picking.in and out to use copy method of stock.picking. For partial delivery, the duplicated picking is the delivered order and the existing picking is the backorder of the delivery (why so much hate?). This means we have to switch the delivery info between the backorder and the delivered picking. Combo opw 615593 and 618802
This commit is contained in:
parent
30a7bea024
commit
f406847613
|
@ -140,7 +140,33 @@ class stock_picking(osv.osv):
|
|||
'weight_uom_id': lambda self,cr,uid,c: self._get_default_uom(cr,uid,c)
|
||||
}
|
||||
|
||||
stock_picking()
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
default = dict(default or {},
|
||||
number_of_packages=0,
|
||||
carrier_tracking_ref=False,
|
||||
volume=0.0)
|
||||
return super(stock_picking, self).copy(cr, uid, id, default=default, context=context)
|
||||
|
||||
def do_partial(self, cr, uid, ids, partial_datas, context=None):
|
||||
res = super(stock_picking, self).do_partial(cr, uid, ids, partial_datas, context=context)
|
||||
for backorder_id, picking_vals in res.iteritems():
|
||||
if backorder_id != picking_vals.get('delivered_picking'):
|
||||
# delivery info is set on backorder but not on new picking
|
||||
backorder = self.browse(cr, uid, backorder_id, context=context)
|
||||
self.write(cr, uid, picking_vals['delivered_picking'], {
|
||||
'carrier_tracking_ref': backorder.carrier_tracking_ref,
|
||||
'number_of_packages': backorder.number_of_packages,
|
||||
'volume': backorder.volume,
|
||||
}, context=context)
|
||||
# delivery info are not relevant to backorder
|
||||
self.write(cr, uid, backorder_id, {
|
||||
'carrier_tracking_ref': False,
|
||||
'number_of_packages': 0,
|
||||
'volume': 0,
|
||||
}, context=context)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
class stock_move(osv.osv):
|
||||
_inherit = 'stock.move'
|
||||
|
|
|
@ -3056,6 +3056,10 @@ class stock_picking_in(osv.osv):
|
|||
defaults.update(in_defaults)
|
||||
return defaults
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
return self.pool['stock.picking'].copy(cr, uid, id, default=default, context=context)
|
||||
|
||||
|
||||
_columns = {
|
||||
'backorder_id': fields.many2one('stock.picking.in', 'Back Order of', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="If this shipment was split, then this field links to the shipment which contains the already processed part.", select=True),
|
||||
'state': fields.selection(
|
||||
|
@ -3129,6 +3133,10 @@ class stock_picking_out(osv.osv):
|
|||
defaults.update(out_defaults)
|
||||
return defaults
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
return self.pool['stock.picking'].copy(cr, uid, id, default=default, context=context)
|
||||
|
||||
|
||||
_columns = {
|
||||
'backorder_id': fields.many2one('stock.picking.out', 'Back Order of', states={'done':[('readonly', True)], 'cancel':[('readonly',True)]}, help="If this shipment was split, then this field links to the shipment which contains the already processed part.", select=True),
|
||||
'state': fields.selection(
|
||||
|
|
Loading…
Reference in New Issue