[IMP] Change quant_search and adapt fifo return test to use real cost

bzr revid: jco@openerp.com-20140130125331-lr70oun5h1uh5w8s
This commit is contained in:
Josse Colpaert 2014-01-30 13:53:31 +01:00
parent d93a12588f
commit f9f1cc2831
2 changed files with 8 additions and 12 deletions

View File

@ -74,7 +74,7 @@
return_picking_id, dummy = self._create_returns(cr, uid, [return_id], context={'active_id': pick_ids[0].id})
self.pool.get('stock.picking').do_transfer(cr, uid, [return_picking_id])
-
Check the standard price of the product changed to 70.0 (as returns to supplier are processed as normal outgoing shipment we have sent 10kg at 50€ and 20kg at 80€, because of FIFO, so the average to store on the product is 70€)
Check the standard price of the product changed to 80.0 as we returned the quants of purchase order 2
-
!python {model: product.product}: |
assert self.browse(cr, uid, ref("product_fiforet_icecream")).standard_price == 70.0, 'Standard price should have changed to 70.0! %s found instead' % (self.browse(cr, uid, ref("product_fiforet_icecream")).standard_price,)
assert self.browse(cr, uid, ref("product_fiforet_icecream")).standard_price == 80.0, 'Standard price should have changed to 80.0! %s found instead' % (self.browse(cr, uid, ref("product_fiforet_icecream")).standard_price,)

View File

@ -72,8 +72,6 @@ class stock_return_picking(osv.osv_memory):
raise osv.except_osv(_('Warning!'), _("You may only return pickings that are Done!"))
#Check if chained moves are not done already. In the mean time, sum the quants in that location
all_moves = []
quants = []
for move in pick.move_lines:
if move.move_dest_id:
move_dest = True
@ -85,14 +83,12 @@ class stock_return_picking(osv.osv_memory):
#Search quants
quant_search = quant_obj.search(cr, uid, ['&', '&', ('history_ids', 'in', move.id), ('qty', '>', 0.0),
('location_id', 'child_of', move.location_dest_id.id)], context=context)
quants += [(move.id, x) for x in quant_obj.browse(cr, uid, quant_search, context=context) if not x.reservation_id or x.reservation_id.origin_returned_move_id.id != move.id]
# Still need to group by move/product? (move has only one product => ...)
for quant in quants:
result1.append({'product_id': quant[1].product_id.id, 'quantity': quant[1].qty, 'move_id': quant[0]})
qty = 0
for quant in quant_obj.browse(cr, uid, quant_search, context=context):
if not quant.reservation_id or quant.reservation_id.origin_returned_move_id.id != move.id:
qty += quant.qty
result1.append({'product_id': move.product_id.id, 'quantity': qty, 'move_id': move.id})
if len(result1) == 0:
raise osv.except_osv(_('Warning!'), _("No products to return (only lines in Done state and not fully returned yet can be returned)!"))
if 'product_return_moves' in fields: