[FIX] purchase: fifo_returns.yml
bzr revid: qdp-launchpad@openerp.com-20130904091256-el137c6uxcppgfcl
This commit is contained in:
@@ -44,7 +44,6 @@ class stock_picking(osv.osv):
|
||||
_columns = {
|
||||
'purchase_id': fields.many2one('purchase.order', 'Purchase Order',
|
||||
ondelete='set null', select=True),
|
||||
'warehouse_id': fields.related('purchase_id', 'warehouse_id', type='many2one', relation='stock.warehouse', string='Destination Warehouse'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
default_code: FIFO
|
||||
name: FIFO Ice Cream
|
||||
type: product
|
||||
standard_price: 0.0
|
||||
categ_id: product.product_category_1
|
||||
uom_id: product.product_uom_kgm
|
||||
uom_po_id: product.product_uom_kgm
|
||||
@@ -46,10 +47,9 @@
|
||||
-
|
||||
Process the reception of purchase order 1
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fiforet1")).picking_ids
|
||||
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
|
||||
self.do_partial(cr, uid, [partial_id])
|
||||
!python {model: stock.picking}: |
|
||||
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fiforet1")).picking_ids[0]
|
||||
self.do_partial(cr,uid,[picking_obj.id], context=context)
|
||||
-
|
||||
Check the standard price of the product (fifo icecream)
|
||||
-
|
||||
@@ -62,23 +62,19 @@
|
||||
-
|
||||
Process the reception of purchase order 2
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fiforet2")).picking_ids
|
||||
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
|
||||
self.do_partial(cr, uid, [partial_id])
|
||||
!python {model: stock.picking}: |
|
||||
picking_obj = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fiforet2")).picking_ids[0]
|
||||
self.do_partial(cr,uid,[picking_obj.id], context=context)
|
||||
-
|
||||
Return the goods of purchase order 2
|
||||
-
|
||||
!python {model: stock.return.picking}: |
|
||||
pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fiforet2")).picking_ids
|
||||
return_id = self.create(cr, uid, {}, context={'active_model':'stock.picking', 'active_id': pick_ids[0].id})
|
||||
res = self.create_returns(cr, uid, [return_id], context={'active_id': pick_ids[0].id})
|
||||
return_move_id = self.pool.get("stock.move").search(cr, uid, [('move_returned_from','=', pick_ids[0].move_lines[0].id)])
|
||||
movepick_obj = self.pool.get("stock.partial.move")
|
||||
movepick_id = movepick_obj.create(cr, uid, {}, context={'active_model': 'stock.move', 'active_ids': return_move_id})
|
||||
movepick_obj.do_partial(cr, uid, [movepick_id])
|
||||
return_picking_id, dummy = self._create_returns(cr, uid, [return_id], context={'active_id': pick_ids[0].id})
|
||||
self.pool.get('stock.picking').do_partial(cr, uid, [return_picking_id])
|
||||
-
|
||||
Check the standard price of the product (fifo return icecream) changed to 70.0
|
||||
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€)
|
||||
-
|
||||
!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!'
|
||||
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,)
|
||||
|
||||
@@ -80,16 +80,7 @@ class stock_return_picking(osv.osv_memory):
|
||||
res.update({'product_return_moves': result1})
|
||||
return res
|
||||
|
||||
def create_returns(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Creates return picking.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: List of ids selected
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
def _create_returns(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
record_id = context and context.get('active_id', False) or False
|
||||
@@ -136,9 +127,22 @@ class stock_return_picking(osv.osv_memory):
|
||||
|
||||
pick_obj.action_confirm(cr, uid, [new_picking], context=context)
|
||||
pick_obj.force_assign(cr, uid, [new_picking], context)
|
||||
return new_picking, pick_type_id
|
||||
|
||||
def create_returns(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Creates return picking.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param ids: List of ids selected
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
new_picking_id, pick_type_id = self._create_returns(cr, uid, ids, context=context)
|
||||
ctx = {'default_picking_type_id': pick_type_id}
|
||||
return {
|
||||
'domain': "[('id', 'in', [" + str(new_picking) + "])]",
|
||||
'domain': "[('id', 'in', [" + str(new_picking_id) + "])]",
|
||||
'name': _('Returned Picking'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
|
||||
Reference in New Issue
Block a user