[IMP,ADD,MOVE]puchase_requisition:

Improve the code in purchase_requisition.yml file
Create new ui folder
Move purchase_requisition_exclusive.yml to onchange_events.yml
Improve code for onchange_events.yml

bzr revid: dbr@tinyerp.com-20111031115225-1yy9jsz3iee2gmlw
This commit is contained in:
DBR (OpenERP)
2011-10-31 17:22:25 +05:30
parent adc05bc4d6
commit a8ee7baa2d
4 changed files with 38 additions and 122 deletions
+2 -1
View File
@@ -43,8 +43,9 @@ This new object will regroup and will allow you to easily keep track and order a
"security/ir.model.access.csv","purchase_requisition_sequence.xml"
],
"active": False,
"test":[#'test/purchase_requisition_report.yml',
"test":[
'test/process/purchase_requisition.yml',
'test/ui/onchange_events.yml',
],
"installable": True,
"certificate" : "001023264099823179629",
@@ -1,6 +1,6 @@
-
In order to test the purchase requisition module, I have to add a boolean field in product,
If I checked it then it's requisition create.
In order to test the purchase requisition module, I have to checked a boolean field 'purchase requisition' in product,
If I checked it then it's requisition will be create.
-
I start by Checking the product, Product must have requisition field checked.
and Product supply method is buy and the procure method is make to order.
@@ -9,7 +9,7 @@
supply_method: 'buy'
purchase_requisition: True
-
I create the procurement order for the product and after run the procurement create purchase requisition.
I create the procurement order for the product and after run that procurement for create purchase requisition.
-
!python {model: product.product}: |
import time
@@ -17,6 +17,7 @@
mk_proc = self.pool.get('make.procurement')
proc_order = self.pool.get('procurement.order')
pur_req = self.pool.get('purchase.requisition')
pur_order = self.pool.get('purchase.order')
context = {'active_model': 'product.product','active_ids': [ref('product.product_product_hdd3')],'active_id': ref('product.product_product_hdd3')}
default_data = mk_proc.default_get(cr, uid, ['uom_id', 'warehouse_id', 'date_planned', 'product_id', 'qty'], context)
vals = {'uom_id': ref('product.product_uom_unit'),'warehouse_id': ref('stock.stock_warehouse_shop0'),'qty': default_data.get('qty'),'date_planned': default_data.get('date_planned')}
@@ -32,11 +33,15 @@
wf_service.trg_validate(uid, 'procurement.order',proc.id,'button_check', cr)
proc_ids = proc_order.search(cr, uid, [('id','=',req_id.get('res_id')),('state','in',['running'])])
proc_id = proc_order.browse(cr, uid, proc_ids)
assert proc_id[0].state == 'running',"Product's UOM is not correspond in procurement order"
assert proc_id[0].state == 'running',"Generated Procurement should be in Running state"
if proc_id[0].requisition_id:
po_id = pur_order.search(cr, uid, [('requisition_id','=',proc_id[0].requisition_id.id)])
po_req = pur_order.browse(cr, uid, po_id)[0].requisition_id
pur_req_rec = pur_req.browse(cr, uid, [proc_id[0].requisition_id.id])
assert pur_req_rec[0].state == 'draft',"Product's UOM is not correspond in procurement order"
assert po_req == proc_id[0].requisition_id,"Created Requisition is not properly linked in purchase order"
assert pur_req_rec[0].state == 'draft',"Created Requisition should be in draft state"
for record in pur_req_rec[0].line_ids:
assert record.product_id.id == ref('product.product_product_hdd3'),"Product's UOM is not correspond in procurement order"
assert record.product_qty == default_data.get('qty'),"Product's UOM is not correspond in procurement order"
assert record.product_uom_id.id == ref('product.product_uom_unit'),"Product's UOM is not correspond in procurement order"
assert record.product_id.id == ref('product.product_product_hdd3'),"Requisition Product is not correspond"
assert record.product_qty == default_data.get('qty'),"Requisition Product's quantity is not correspond"
assert record.product_uom_id.id == ref('product.product_uom_unit'),"Requisition Product's UOM is not correspond"
@@ -1,113 +0,0 @@
-
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')
@@ -0,0 +1,23 @@
-
In order to test the onchange events of purchase requisition.
-
I call onchange event to change the product of purchase requisition line.
-
!python {model: purchase.requisition.line}: |
self.onchange_product_id(cr, uid, [ref('order_purchase_requisition1')],ref('product.product_product_hdd2'), ref('product.product_uom_unit'))
-
I change state of requisition in "In progress".
-
!python {model: purchase.requisition}: |
self.tender_in_progress(cr, uid, ref('order_purchase_requisition1'))
-
I change state of requisition as "done".
-
!python {model: purchase.requisition}: |
self.tender_done(cr, uid, ref('order_purchase_requisition1'))
-
I reset the state of requisition as "New".
-
!python {model: purchase.requisition}: |
self.tender_reset(cr, uid, ref('order_purchase_requisition1'))