From 5edd024e3a4af5ce818fcde38cee44d8956a4477 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 28 Sep 2015 22:20:03 +0200 Subject: [PATCH] [FIX] point_of_sale: pickings should be transferred the new way Also for returns, make sure the picking gets the correct locations already. --- addons/point_of_sale/point_of_sale.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 84635131d6f..81dace6e354 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -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)