diff --git a/addons/purchase/test/fifo_price.yml b/addons/purchase/test/fifo_price.yml index e6488bcc141..258d523815e 100644 --- a/addons/purchase/test/fifo_price.yml +++ b/addons/purchase/test/fifo_price.yml @@ -53,10 +53,9 @@ - Process the reception of purchase order 1 and set date - - !python {model: stock.partial.picking}: | - pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo1")).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_fifo1")).picking_ids[0] + picking_obj.do_partial(context=context) - Check the standard price of the product (fifo icecream) - @@ -69,10 +68,9 @@ - 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_fifo2")).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_fifo2")).picking_ids[0] + picking_obj.do_partial(context=context) - A purchase order towards the Chicago shop TODO code for receiving - @@ -96,7 +94,7 @@ Let us send some goods - !record {model: stock.picking, id: outgoing_fifo_shipment}: - type: out + picking_type_id: stock.picking_type_out - Picking needs movement from stock - @@ -105,7 +103,9 @@ product_id: product_fifo_icecream product_uom: product.product_uom_kgm product_qty: 20.0 - type: out + location_id: stock.stock_location_stock + location_dest_id: stock.stock_location_customers + picking_type_id: stock.picking_type_out - I assign this outgoing shipment - @@ -114,9 +114,9 @@ - Process the delivery of the outgoing shipment - - !python {model: stock.partial.picking}: | - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment")], 'default_type':'out'}) - self.do_partial(cr, uid, [partial_id]) + !python {model: stock.picking}: | + pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment")) + pick_obj.do_partial(context=context) - Check product standard price changed to 65.0 - @@ -126,7 +126,7 @@ Do a delivery of an extra 500 g (delivery order) - !record {model: stock.picking, id: outgoing_fifo_shipment_uom}: - type: out + picking_type_id: stock.picking_type_out - Picking needs movement from stock - @@ -134,8 +134,10 @@ picking_id: outgoing_fifo_shipment_uom product_id: product_fifo_icecream product_uom: product.product_uom_gram + location_id: stock.stock_location_stock + location_dest_id: stock.stock_location_customers product_qty: 500.0 - type: out + picking_type_id: stock.picking_type_out - I assign this outgoing shipment - @@ -144,9 +146,9 @@ - Process the delivery of the outgoing shipment - - !python {model: stock.partial.picking}: | - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_uom")], 'default_type':'out'}) - self.do_partial(cr, uid, [partial_id]) + !python {model: stock.picking}: | + pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_uom")) + pick_obj.do_partial(context=context) - Check product price changed to 80.0 - @@ -201,15 +203,14 @@ - Process the reception of purchase order with usd - - !python {model: stock.partial.picking}: | - pick_ids = self.pool.get('purchase.order').browse(cr, uid, ref("purchase_order_fifo_usd")).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}: | + pick_obj = self.pool.get('stock.picking').browse(cr, uid, ref("purchase_order_fifo_usd")) + pick_obj.do_partial(context=context) - We create delivery order of 49.5 kg - !record {model: stock.picking, id: outgoing_fifo_shipment_cur}: - type: out + picking_type_id: stock.picking_type_out - Picking needs movement from stock - @@ -218,7 +219,9 @@ product_id: product_fifo_icecream product_uom: product.product_uom_kgm product_qty: 49.5 - type: out + location_id: stock.stock_location_stock + location_dest_id: stock.stock_location_customers + picking_type_id: stock.picking_type_out - I assign this outgoing shipment - @@ -227,9 +230,9 @@ - Process the delivery of the outgoing shipment - - !python {model: stock.partial.picking}: | - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_cur")], 'default_type':'out'}) - self.do_partial(cr, uid, [partial_id]) + !python {model: stock.picking}: | + picking_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_cur")) + picking_obj.do_partial(context=context) - Check rounded price is 102 euro - @@ -239,7 +242,7 @@ Do a delivery of an extra 10 kg - !record {model: stock.picking, id: outgoing_fifo_shipment_ret}: - type: out + picking_type_id: stock.picking_type_out - Picking needs movement from stock - @@ -248,7 +251,9 @@ product_id: product_fifo_icecream product_uom: product.product_uom_kgm product_qty: 10.0 - type: out + location_id: stock.stock_location_stock + location_dest_id: stock.stock_location_customers + picking_type_id: stock.picking_type_out - I assign this outgoing shipment - @@ -257,9 +262,9 @@ - Process the delivery of the outgoing shipment - - !python {model: stock.partial.picking}: | - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_ret")], 'default_type':'out'}) - self.do_partial(cr, uid, [partial_id]) + !python {model: stock.picking}: | + picking_obj = self.pool.get('stock.picking').browse(cr, uid, ref("outgoing_fifo_shipment_ret")) + picking_obj.do_partial(context=context) - Check rounded price is 150.0 / 1.2834 - @@ -269,7 +274,7 @@ Let us create some outs to get negative stock. Create outpicking. We create delivery order of 200 kg, but will pick only 100 kg - !record {model: stock.picking, id: outgoing_fifo_shipment_neg}: - type: out + picking_type_id: stock.picking_type_out - Picking needs movement from stock - @@ -278,12 +283,14 @@ product_id: product_fifo_icecream product_uom: product.product_uom_kgm product_qty: 200.0 - type: out + location_id: stock.stock_location_stock + location_dest_id: stock.stock_location_customers + picking_type_id: stock.picking_type_out - Let us create another out of 400 kg, but will pick only 50 kg - !record {model: stock.picking, id: outgoing_fifo_shipment_neg2}: - type: out + picking_type_id: stock.picking_type_out - Picking needs movement from stock - @@ -292,19 +299,17 @@ product_id: product_fifo_icecream product_uom: product.product_uom_kgm product_qty: 400.0 - type: out + location_id: stock.stock_location_stock + location_dest_id: stock.stock_location_customers + picking_type_id: stock.picking_type_out - Process the delivery of the outgoing shipments - - !python {model: stock.partial.picking}: | - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_neg")], 'default_type':'out'}) - line = self.browse(cr, uid, partial_id, context=context).move_ids[0] - self.pool.get("stock.partial.picking.line").write(cr, uid, [line.id], {'quantity':100}) - self.do_partial(cr, uid, [partial_id]) - partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_neg2")], 'default_type':'out'}) - line = self.browse(cr, uid, partial_id, context=context).move_ids[0] - self.pool.get("stock.partial.picking.line").write(cr, uid, [line.id], {'quantity':50}) - self.do_partial(cr, uid, [partial_id]) + !python {model: stock.picking}: | + picking_obj = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg")) + picking_obj.do_partial(context=context) + picking_obj1 = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg2")) + picking_obj1.do_partial(context=context) - Receive purchase order with 50 kg FIFO Ice Cream at 50 euro/kg - @@ -325,10 +330,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_fifo_neg")).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_fifo_neg")).picking_ids[0] + picking_obj.do_partial(context=context) - Assert price on product is still the old price as the out move has not been received fully yet - @@ -354,10 +358,9 @@ - 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_fifo_neg2")).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_fifo_neg2")).picking_ids[0] + picking_obj.do_partial(context=context) - The price of the product should have changed back to 65.0 -