[FIX] point_of_sale: fix default destination(or source, for returns) location for pos order moves

For instance, the source location of moves of returned products was output instead of partners locations / customers

bzr revid: dle@openerp.com-20131210181733-2rjw6cas8bjypp2p
This commit is contained in:
Denis Ledoux 2013-12-10 19:17:33 +01:00
parent 1734cea7d6
commit 34c6eb963a
1 changed files with 6 additions and 7 deletions

View File

@ -698,13 +698,14 @@ class pos_order(osv.osv):
}, context=context)
self.write(cr, uid, [order.id], {'picking_id': picking_id}, context=context)
location_id = order.shop_id.warehouse_id.lot_stock_id.id
output_id = order.shop_id.warehouse_id.lot_output_id.id
if order.partner_id:
destination_id = order.partner_id.property_stock_customer.id
else:
destination_id = partner_obj.default_get(cr, uid, ['property_stock_customer'], context=context)['property_stock_customer']
for line in order.lines:
if line.product_id and line.product_id.type == 'service':
continue
if line.qty < 0:
location_id, output_id = output_id, location_id
move_obj.create(cr, uid, {
'name': line.name,
@ -716,11 +717,9 @@ class pos_order(osv.osv):
'product_qty': abs(line.qty),
'tracking_id': False,
'state': 'draft',
'location_id': location_id,
'location_dest_id': output_id,
'location_id': location_id if line.qty >= 0 else destination_id,
'location_dest_id': destination_id if line.qty >= 0 else location_id,
}, context=context)
if line.qty < 0:
location_id, output_id = output_id, location_id
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)