[FIX] point_of_sale: pickings should be transferred the new way
Also for returns, make sure the picking gets the correct locations already.
This commit is contained in:
@@ -919,13 +919,17 @@ class pos_order(osv.osv):
|
||||
location_id = order.location_id.id
|
||||
if order.partner_id:
|
||||
destination_id = order.partner_id.property_stock_customer.id
|
||||
elif picking_type:
|
||||
if not picking_type.default_location_dest_id:
|
||||
raise UserError(_('Missing source or destination location for picking type %s. Please configure those fields and try again.' % (picking_type.name,)))
|
||||
destination_id = picking_type.default_location_dest_id.id
|
||||
else:
|
||||
destination_id = partner_obj.default_get(cr, uid, ['property_stock_customer'], context=context)['property_stock_customer']
|
||||
if (not picking_type) or (not picking_type.default_location_dest_id):
|
||||
customerloc, supplierloc = self.pool['stock.warehouse']._get_partner_locations(cr, uid, [], context=context)
|
||||
destination_id = customerloc.id
|
||||
else:
|
||||
destination_id = picking_type.default_location_dest_id.id
|
||||
|
||||
#All qties negative => Create negative
|
||||
if picking_type:
|
||||
pos_qty = all([x.qty >= 0 for x in order.lines])
|
||||
#Check negative quantities
|
||||
picking_id = picking_obj.create(cr, uid, {
|
||||
'origin': order.name,
|
||||
'partner_id': addr.get('delivery',False),
|
||||
@@ -934,8 +938,8 @@ class pos_order(osv.osv):
|
||||
'company_id': order.company_id.id,
|
||||
'move_type': 'direct',
|
||||
'note': order.note or "",
|
||||
'location_id': location_id,
|
||||
'location_dest_id': destination_id,
|
||||
'location_id': location_id if pos_qty else destination_id,
|
||||
'location_dest_id': destination_id if pos_qty else location_id,
|
||||
}, context=context)
|
||||
self.write(cr, uid, [order.id], {'picking_id': picking_id}, context=context)
|
||||
|
||||
@@ -959,6 +963,10 @@ class pos_order(osv.osv):
|
||||
if picking_id:
|
||||
picking_obj.action_confirm(cr, uid, [picking_id], context=context)
|
||||
picking_obj.force_assign(cr, uid, [picking_id], context=context)
|
||||
# Mark pack operations as done
|
||||
pick = picking_obj.browse(cr, uid, picking_id, context=context)
|
||||
for pack in pick.pack_operation_ids:
|
||||
self.pool['stock.pack.operation'].write(cr, uid, [pack.id], {'qty_done': pack.product_qty}, context=context)
|
||||
picking_obj.action_done(cr, uid, [picking_id], context=context)
|
||||
elif move_list:
|
||||
move_obj.action_confirm(cr, uid, move_list, context=context)
|
||||
|
||||
Reference in New Issue
Block a user