From 5fa1ccdcce7b15b1747a76dafc945ae2c24cbdb7 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 2 Sep 2015 08:24:55 +0200 Subject: [PATCH] [IMP] stock_dropshipping: adaptation due to the new Purchase module Major changes: - Adaptation of tests Reason: complete rewrite of the Purchase module. Responsible: fp, nim --- .../test/cancellation_propagated.yml | 14 +++++++------- addons/stock_dropshipping/test/crossdock.yml | 2 +- addons/stock_dropshipping/test/dropship.yml | 8 ++++---- addons/stock_dropshipping/test/lifo_price.yml | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/addons/stock_dropshipping/test/cancellation_propagated.yml b/addons/stock_dropshipping/test/cancellation_propagated.yml index efadd6e8ef0..15af60ebe83 100644 --- a/addons/stock_dropshipping/test/cancellation_propagated.yml +++ b/addons/stock_dropshipping/test/cancellation_propagated.yml @@ -87,15 +87,19 @@ purchase_ids = [proc.purchase_line_id.order_id for proc in self.browse(cr, uid, procu_ids) if proc.purchase_line_id] assert len(purchase_ids) == 1, 'No purchase order found !' - # Check the total quantity on the purchase order which should be in Unit(s) + # Check the two purchase order lines + purchase_line = purchase_ids[0].order_line[0] - assert purchase_line.product_qty == 29.0, 'As we ordered 2 Dozen(s) and 5 Unit(s), total should be 29 Unit(s) and not %s' % (purchase_line.product_qty,) + assert purchase_line.product_qty == 5.0, 'The product quantity of the first order line should be 5 and not %s' % (purchase_line.product_qty,) + assert purchase_line.product_uom.id == ref("product.product_uom_unit"), 'The product UoM ID of the first order line should be %s and not %s' % (ref("product.product_uom_unit"), purchase_line.product_uom.id,) + purchase_line = purchase_ids[0].order_line[1] + assert purchase_line.product_qty == 2.0, 'The product quantity of the first order line should be 2 and not %s' % (purchase_line.product_qty,) + assert purchase_line.product_uom.id == ref("product.product_uom_dozen"), 'The product UoM ID of the second order line should be %s and not %s' % (ref("product.product_uom_dozen"), purchase_line.product_uom.id,) # Let us cancel the procurement related to the 2nd sales order first and check that the 2 Dozen(s) are subtracted correctly so2 = self.pool.get('sale.order').browse(cr, uid, ref('sale_order_product_mto2')) self.cancel(cr, uid, [so2.order_line[0].procurement_ids[0].id], context=context) assert so2.order_line[0].procurement_ids[0].state == u'cancel', 'Main procurement should be cancelled !' - assert purchase_line.product_qty == 5.0, 'As we ordered 2 Dozen(s) and 5 Unit(s) and cancelled the two Dozen, total should be 5 Unit(s) and not %s' % (purchase_line.product_qty,) # Cancel the main procurement from the sale order in units main_procu_id = self.search(cr, uid, [('origin', '=', so.name)]) @@ -106,7 +110,3 @@ # Check that all procurements related are cancelled for procu in self.browse(cr, uid, procu_ids, context=context): assert procu.state == u'cancel', 'Procurement %d should be cancelled but is with a state : %s!' %(procu.id, procu.state) - - # Check that the purchase order is cancelled - for po in self.pool.get('purchase.order').browse(cr, uid, [po.id for po in purchase_ids], context=context): - assert po.state == u'cancel', 'Purchase order %d should be cancelled but is in state : %s!' %(po.id, po.state) diff --git a/addons/stock_dropshipping/test/crossdock.yml b/addons/stock_dropshipping/test/crossdock.yml index e32ee6fcca9..2b284df1365 100644 --- a/addons/stock_dropshipping/test/crossdock.yml +++ b/addons/stock_dropshipping/test/crossdock.yml @@ -56,4 +56,4 @@ - !python {model: purchase.order}: | po_id = self.search(cr, uid, [('partner_id', '=', ref('supplier_crossdock')), ('state','=','draft')]) - self.wkf_confirm_order(cr, uid, po_id) + self.button_confirm(cr, uid, po_id) diff --git a/addons/stock_dropshipping/test/dropship.yml b/addons/stock_dropshipping/test/dropship.yml index d158c44c78f..1f51983c46e 100644 --- a/addons/stock_dropshipping/test/dropship.yml +++ b/addons/stock_dropshipping/test/dropship.yml @@ -47,20 +47,20 @@ Check a quotation was created to a certain vendor and confirm so it becomes a confirmed purchase order - !python {model: purchase.order}: | - from openerp import netsvc, workflow + from openerp import netsvc sale_record = self.pool.get("sale.order").browse(cr, uid, ref('sale_order_drp_shpng')) procurement_order = self.pool.get("procurement.group").browse(cr, uid, sale_record.procurement_group_id.id).procurement_ids[0] purchase_id = procurement_order.purchase_line_id.order_id.id - workflow.trg_validate(uid, 'purchase.order', purchase_id, 'purchase_confirm', cr) + self.button_confirm(cr, uid, purchase_id) po_id = self.pool.get('purchase.order').search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))]) - assert self.browse(cr, uid, purchase_id).state == 'approved', 'Purchase order should be in the approved state' + assert self.browse(cr, uid, purchase_id).state == 'purchase', 'Purchase order should be in the approved state' - Use 'Receive Products' button to immediately view this picking, it should have created a picking with 200 pieces - !python {model: purchase.order}: | po_id = self.search(cr, uid, [('partner_id', '=', ref('supplier_dropship'))]) - self.view_picking(cr, uid, po_id) + assert len(po_id) == 1, 'There should be one picking' - Send the 200 pieces. - diff --git a/addons/stock_dropshipping/test/lifo_price.yml b/addons/stock_dropshipping/test/lifo_price.yml index aa6903e0a22..ffcf2979bef 100644 --- a/addons/stock_dropshipping/test/lifo_price.yml +++ b/addons/stock_dropshipping/test/lifo_price.yml @@ -32,7 +32,6 @@ - !record {model: purchase.order, id: purchase_order_lifo1}: partner_id: base.res_partner_3 - location_id: stock.stock_location_stock order_line: - product_id: product_lifo_icecream product_qty: 10.0 @@ -44,7 +43,6 @@ - !record {model: purchase.order, id: purchase_order_lifo2}: partner_id: base.res_partner_3 - location_id: stock.stock_location_stock order_line: - product_id: product_lifo_icecream product_qty: 30.0 @@ -54,12 +52,13 @@ - I confirm the first purchase order - - !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_lifo1} + !python {model: purchase.order}: | + self.button_confirm(cr, uid, [ref("purchase_order_lifo1")]) - I check the "Approved" status of purchase order 1 - !assert {model: purchase.order, id: purchase_order_lifo1}: - - state == 'approved' + - state == 'purchase' - Process the receipt of purchase order 1 - @@ -74,7 +73,8 @@ - I confirm the second purchase order - - !workflow {model: purchase.order, action: purchase_confirm, ref: purchase_order_lifo2} + !python {model: purchase.order}: | + self.button_confirm(cr, uid, [ref("purchase_order_lifo2")]) - Process the receipt of purchase order 2 -