Task 617:purchase_requisition Create a test case
bzr revid: sbh@tinyerp.com-20100428094746-t6hqk6cfid80v7zl
This commit is contained in:
parent
f10e9aeca2
commit
e7fd6c656d
|
@ -34,7 +34,8 @@
|
|||
"update_xml" : ["wizard/purchase_requisition_partner_view.xml",
|
||||
"purchase_requisition_view.xml",
|
||||
"security/ir.model.access.csv","purchase_requisition_sequence.xml"],
|
||||
|
||||
"test":['test/purchase_requisition_test.yml',
|
||||
'test/purchase_requisition_exclusive_test.yml'],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
-
|
||||
In order to test the purchase requicisition module, I will do a sale order -> purchase_requisition ->
|
||||
purchase flow and I will buy the required products at two different suppliers.
|
||||
-
|
||||
I start by creating a new product 'Laptop ACER', which is purchased at Asustek, in MTO,
|
||||
with the generation of purchase requisitions.
|
||||
-
|
||||
Creating an product.product record
|
||||
-
|
||||
!record {model: product.product, id: product_product_laptopacer0}:
|
||||
categ_id: product.product_category_3
|
||||
cost_method: standard
|
||||
list_price: 1000.0
|
||||
mes_type: fixed
|
||||
name: Laptop ACER1
|
||||
procure_method: make_to_order
|
||||
purchase_requisition: 1
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: base.res_partner_asus
|
||||
qty: 5.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
-
|
||||
Creating an sale.order record
|
||||
-
|
||||
!record {model: sale.order, id: sale_order_testtender0}:
|
||||
date_order: '2010-04-20'
|
||||
invoice_quantity: order
|
||||
name: TEST/TENDER/0002
|
||||
order_line:
|
||||
- name: Laptop ACER1
|
||||
price_unit: 1000.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uom_qty: 5.0
|
||||
state: draft
|
||||
'delay': 7.0
|
||||
'product_id': product_product_laptopacer0
|
||||
'type': make_to_order
|
||||
order_policy: manual
|
||||
partner_id: base.res_partner_agrolait
|
||||
partner_invoice_id: base.res_partner_address_8
|
||||
partner_order_id: base.res_partner_address_8
|
||||
partner_shipping_id: base.res_partner_address_8
|
||||
picking_policy: direct
|
||||
pricelist_id: product.list0
|
||||
shop_id: sale.shop
|
||||
-
|
||||
Performing a workflow action order_confirm on module sale.order
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender0}
|
||||
-
|
||||
I launch he scheduler to compute all procurements, and planify all requisitions order
|
||||
-
|
||||
!python {model: mrp.procurement.compute.all}: |
|
||||
proc_obj = self.pool.get('mrp.procurement')
|
||||
proc_obj._procure_confirm(cr,uid)
|
||||
|
||||
-
|
||||
Creating an purchase.requisition record
|
||||
-
|
||||
!record {model: purchase.requisition.partner, id: purchase_requisition_partner_1}:
|
||||
partner_id: base.res_partner_4
|
||||
partner_address_id: base.res_partner_address_7
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
requisition_obj = self.pool.get('purchase.requisition.partner')
|
||||
req_obj = self.pool.get('purchase.requisition')
|
||||
ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
|
||||
requisition_obj.create_order(cr,uid, [ref('purchase_requisition_partner_1')],{'active_ids': ids})
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
purchase_obj = self.pool.get('purchase.order')
|
||||
ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0002')])[0]
|
||||
self.write(cr,uid,ids,{'exclusive': 'exclusive' })
|
||||
ids =purchase_obj.search(cr, uid, [('requisition_id','in',[ids])])
|
||||
assert (len(ids)<2),"Purchase Order hasn't Created"
|
||||
-
|
||||
I change the quantities so that the purchase order for DistriPC includes 3 pieces and the
|
||||
purchase order for Asustek includes 2 pieces.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_id= self.search(cr, uid, [('origin','=','TEST/TENDER/0002')])
|
||||
order_line=self.browse(cr, uid, purchase_id, context)[0].order_line[0].id
|
||||
self.pool.get('purchase.order.line').write(cr, uid, [order_line], {'product_qty':5})
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
if purchase_id:
|
||||
wf_service.trg_validate(uid, 'purchase.order',purchase_id[0],'purchase_confirm', cr)
|
||||
wf_service.trg_validate(uid, 'purchase.order',purchase_id[0],'purchase_approve', cr)
|
||||
-
|
|
@ -0,0 +1,110 @@
|
|||
-
|
||||
In order to test the purchase requicisition module, I will do a sale order -> purchase_requisition ->
|
||||
purchase flow and I will buy the required products at two different suppliers.
|
||||
-
|
||||
I start by creating a new product 'Laptop ACER', which is purchased at Asustek, in MTO,
|
||||
with the generation of purchase requisitions.
|
||||
-
|
||||
Creating an product.product record
|
||||
-
|
||||
!record {model: product.product, id: product_product_laptopacer0}:
|
||||
categ_id: product.product_category_3
|
||||
cost_method: standard
|
||||
list_price: 1000.0
|
||||
mes_type: fixed
|
||||
name: Laptop ACER
|
||||
procure_method: make_to_order
|
||||
purchase_requisition: 1
|
||||
seller_ids:
|
||||
- delay: 1
|
||||
name: base.res_partner_asus
|
||||
qty: 5.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
-
|
||||
Creating an sale.order record
|
||||
-
|
||||
!record {model: sale.order, id: sale_order_so0}:
|
||||
date_order: '2010-04-20'
|
||||
invoice_quantity: order
|
||||
name: TEST/TENDER/0001
|
||||
order_line:
|
||||
- name: Laptop ACER
|
||||
price_unit: 1000.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uom_qty: 5.0
|
||||
state: draft
|
||||
'delay': 7.0
|
||||
'product_id': product_product_laptopacer0
|
||||
'type': make_to_order
|
||||
order_policy: manual
|
||||
partner_id: base.res_partner_agrolait
|
||||
partner_invoice_id: base.res_partner_address_8
|
||||
partner_order_id: base.res_partner_address_8
|
||||
partner_shipping_id: base.res_partner_address_8
|
||||
picking_policy: direct
|
||||
pricelist_id: product.list0
|
||||
shop_id: sale.shop
|
||||
-
|
||||
Performing a workflow action order_confirm on module sale.order
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
|
||||
-
|
||||
I launch he scheduler to compute all procurements, and planify all requisitions order
|
||||
-
|
||||
!python {model: mrp.procurement.compute.all}: |
|
||||
proc_obj = self.pool.get('mrp.procurement')
|
||||
proc_obj._procure_confirm(cr,uid)
|
||||
|
||||
-
|
||||
Creating an purchase.requisition record
|
||||
-
|
||||
!record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
|
||||
partner_id: base.res_partner_4
|
||||
partner_address_id: base.res_partner_address_7
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
requisition_obj = self.pool.get('purchase.requisition.partner')
|
||||
req_obj = self.pool.get('purchase.requisition')
|
||||
ids =req_obj.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
|
||||
requisition_obj.create_order(cr,uid, [ref('purchase_requisition_partner_0')],{'active_ids': ids})
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
purchase_obj = self.pool.get('purchase.order')
|
||||
requisition_ids= self.search(cr, uid, [],context)
|
||||
ids =purchase_obj.search(cr, uid, [('requisition_id','in',requisition_ids)])
|
||||
assert len(ids) < 2,"Purchase Order hasn't Created"
|
||||
-
|
||||
I change the quantities so that the purchase order for DistriPC includes 3 pieces and the
|
||||
purchase order for Asustek includes 2 pieces.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_id1= self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
|
||||
purchase_id2= self.search(cr, uid, [('origin','=','TE00001')])
|
||||
order_line1=self.browse(cr, uid, purchase_id1, context)[0].order_line[0].id
|
||||
order_line2=self.browse(cr, uid, purchase_id2, context)[0].order_line[0].id
|
||||
self.pool.get('purchase.order.line').write(cr, uid, [order_line1], {'product_qty':2})
|
||||
self.pool.get('purchase.order.line').write(cr, uid, [order_line2], {'product_qty':3})
|
||||
todo=[]
|
||||
todo.append(purchase_id1[0])
|
||||
todo.append(purchase_id2[0])
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for ids in todo:
|
||||
wf_service.trg_validate(uid, 'purchase.order',ids,'purchase_confirm', cr)
|
||||
wf_service.trg_validate(uid, 'purchase.order',ids,'purchase_approve', cr)
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
|
||||
self.tender_done(cr,uid,ids)
|
||||
-
|
||||
I check that the delivery order of the customer is in state 'Waiting Goods'
|
||||
-
|
||||
!python {model: sale.order}: |
|
||||
so = self.browse(cr, uid, ref("sale_order_so0"))
|
||||
assert (so.picking_ids[0].state) =='confirmed',"Delivery Order not confirmed"
|
||||
assert (so.picking_ids[0].move_lines[0].state=='waiting')
|
||||
-
|
||||
I receive the order of the supplier Asustek from the Incoming Products menu
|
Loading…
Reference in New Issue