odoo/addons/purchase_requisition/test/purchase_requisition_exclus...

114 lines
4.5 KiB
YAML

-
In order to test the purchase requisition 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.
-
!record {model: product.product, id: product_product_laptopacer1}:
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
min_qty: 1.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
Then I sell 5 Laptop ACER to the customer Agrolait, sale order TEST/TENDER/0002
-
!record {model: sale.order, id: sale_order_testtender1}:
date_order: !eval time.strftime('%Y-%m-%d')
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_laptopacer1
'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
-
I confirm sale order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender1}
-
I launch the scheduler to compute all procurements, and planify all requisitions orders.
-
!python {model: procurement.order.compute.all}: |
proc_obj = self.pool.get('procurement.order')
proc_obj._procure_confirm(cr,uid)
-
I should find a purchase requisition with the origin 'TEST/TENDER/0002', that includes a request for
5 Laptop ACER, and a purchase order on the default supplier for this product.
-
!python {model: purchase.requisition}: |
requisition_ids =self.search(cr, uid, [('origin','=','Laptop ACER1')])
ids=len(requisition_ids)
assert len(requisition_ids), "Purchase requisition hasn't Created"
-
On the purchase requisition, I create a new purchase order for the supplier 'DistriPC' by clicking on
the button 'New Request for Quotation'. This opens a window to ask me the supplier and I set DistriPC .
-
I Create purchase.requisition.partner .
-
!record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
partner_address_id: base.res_partner_address_7
partner_id: base.res_partner_4
-
I create a new purchase order for the supplier 'DistriPC'.
-
!python {model: purchase.requisition.partner}: |
req_obj = self.pool.get('purchase.requisition')
ids =req_obj.search(cr, uid, [('origin','=','Laptop ACER1')])
self.create_order(cr, uid, [ref("purchase_requisition_partner_0")], {"lang":
'en_US', "active_model": "purchase.requisition", "tz": False, "record_id":
1, "active_ids": ids, "active_id": ids[0], })
-
I set the purchase requisition as 'Exclusive'
-
!python {model: purchase.requisition}: |
ids =self.search(cr, uid, [('origin','=','Laptop ACER1')])
self.write(cr,uid,ids[0],{'exclusive': 'exclusive' })
-
I confirm and validate the Request for Quotation of ASUStek.
-
!python {model: purchase.order}: |
partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','ASUStek')])[0]
req_obj = self.pool.get('purchase.requisition')
ids =req_obj.search(cr, uid, [('origin','=','Laptop ACER1')])
purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','in',ids)])[0]
import netsvc
wf_service = netsvc.LocalService("workflow")
if purchase_id:
wf_service.trg_validate(uid, 'purchase.order',purchase_id,'purchase_confirm', cr)
wf_service.trg_validate(uid, 'purchase.order',purchase_id,'purchase_approve', cr)
-
I check that Request for Quotation of DistriPC is cancelled.
-
!python {model: purchase.order}: |
partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
req_obj = self.pool.get('purchase.requisition')
ids =req_obj.search(cr, uid, [('origin','=','Laptop ACER1')])
purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','in',ids)])[0]
state=self.browse(cr,uid,purchase_id).state
assert (state=='cancel')