[MERGE] merged cleanup yml:
purchase_requisition/purchase_requisition.py * [IMP] call tender_done() method instead of set state manually. purchase_requisition/purchase_requisition_demo.xml * [IMP] added demo data of requisition with RFQs purchase_requisition/wizard/purchase_requisition_partner.py * [IMP] address_id is not mandatory. so remove required tag [IMP] Test cases of requisition process * purchase_requisition.yml * purchase_requisition_demo.yml [REM] * purchase_requisition_exclusive.yml [move into requisition.yml] * purchase_requisition_report.yml [move into requisition.yml] bzr revid: hmo@tinyerp.com-20111202051506-kmlsfqnoqcafkic5
This commit is contained in:
commit
bdf23343b1
|
@ -43,8 +43,10 @@ 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/purchase_requisition_test.yml',
|
||||
"test":[
|
||||
'test/purchase_requisition_demo.yml',
|
||||
'test/purchase_requisition.yml',
|
||||
'test/cancel_purchase_requisition.yml',
|
||||
],
|
||||
"installable": True,
|
||||
"certificate" : "001023264099823179629",
|
||||
|
|
|
@ -133,7 +133,7 @@ class purchase_order(osv.osv):
|
|||
proc_obj.write(cr, uid, proc_ids, {'purchase_id': po.id})
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'purchase.order', order.id, 'purchase_cancel', cr)
|
||||
self.pool.get('purchase.requisition').write(cr, uid, [po.requisition_id.id], {'state':'done','date_end':time.strftime('%Y-%m-%d %H:%M:%S')})
|
||||
po.requisition_id.tender_done(context=context)
|
||||
return res
|
||||
|
||||
purchase_order()
|
||||
|
|
|
@ -6,24 +6,65 @@
|
|||
<field eval="[(4, ref('group_purchase_requisition_user'))]" name="groups_id"/>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_hdd3" model="product.product">
|
||||
<field name="purchase_requisition" eval="True"/>
|
||||
</record>
|
||||
|
||||
<!--Resource: purchase.requisition-->
|
||||
|
||||
<record id="order_purchase_requisition1" model="purchase.requisition">
|
||||
<record id="requisition1" model="purchase.requisition">
|
||||
<field name="user_id" model="res.users"/>
|
||||
<field name="exclusive">multiple</field>
|
||||
<field name="exclusive">exclusive</field>
|
||||
<field name="date_start" eval="time.strftime('%Y/%m/%d %H:%M:%S')"/>
|
||||
<field name="warehouse_id" ref="stock.stock_warehouse_shop0"/>
|
||||
</record>
|
||||
|
||||
<!--Resource: purchase.requisition.line-->
|
||||
|
||||
<record id="line_purchase_requisition1" model="purchase.requisition.line">
|
||||
<field name="requisition_id" ref="order_purchase_requisition1"/>
|
||||
<field name="product_id" ref="product.product_product_pc3"/>
|
||||
<field name="product_uom_id" model="product.uom" search="[]"/>
|
||||
<record id="requisition_line1" model="purchase.requisition.line">
|
||||
<field name="name">[HDD3] HDD Seagate 7200.8 160GB</field>
|
||||
<field name="requisition_id" ref="requisition1"/>
|
||||
<field name="product_id" ref="product.product_product_hdd3"/>
|
||||
<field name="product_uom_id" ref="product.product_uom_unit"/>
|
||||
<field name="product_qty">5</field>
|
||||
</record>
|
||||
|
||||
<!--Resource: purchase.order-->
|
||||
|
||||
<record id="rfq1" model="purchase.order">
|
||||
<field name="location_id" ref="stock.stock_location_stock"/>
|
||||
<field name="pricelist_id" ref="purchase.list0"/>
|
||||
<field name="partner_id" ref="base.res_partner_4"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_7"/>
|
||||
<field name="requisition_id" ref="requisition1"/>
|
||||
</record>
|
||||
|
||||
<record id="rfq1_line" model="purchase.order.line">
|
||||
<field name="order_id" ref="rfq1"/>
|
||||
<field name="name">[HDD3] HDD Seagate 7200.8 160GB</field>
|
||||
<field name="date_planned" eval="time.strftime('%Y/%m/10')"/>
|
||||
<field name="product_id" ref="product.product_product_hdd3"/>
|
||||
<field name="product_uom" ref="product.product_uom_unit"/>
|
||||
<field name="price_unit">60</field>
|
||||
<field name="product_qty">5</field>
|
||||
</record>
|
||||
|
||||
<record id="rfq2" model="purchase.order">
|
||||
<field name="location_id" ref="stock.stock_location_stock"/>
|
||||
<field name="pricelist_id" ref="purchase.list0"/>
|
||||
<field name="partner_id" ref="base.res_partner_vickingdirect0"/>
|
||||
<field name="partner_address_id" ref="base.res_partner_address_brussels0"/>
|
||||
<field name="requisition_id" ref="requisition1"/>
|
||||
</record>
|
||||
|
||||
<record id="rfq2_line" model="purchase.order.line">
|
||||
<field name="order_id" ref="rfq2"/>
|
||||
<field name="name">[HDD3] HDD Seagate 7200.8 160GB</field>
|
||||
<field name="date_planned" eval="time.strftime('%Y/%m/15')"/>
|
||||
<field name="product_id" ref="product.product_product_hdd3"/>
|
||||
<field name="product_uom" ref="product.product_uom_unit"/>
|
||||
<field name="price_unit">50</field>
|
||||
<field name="product_qty">3</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
-
|
||||
I cancel requisition.
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
self.tender_cancel(cr, uid, [ref("requisition1")])
|
||||
-
|
||||
I check requisition after cancelled.
|
||||
-
|
||||
!assert {model: purchase.requisition, id: requisition1}:
|
||||
- state == 'cancel'
|
||||
-
|
||||
I reset requisition as "New".
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
self.tender_reset(cr, uid, [ref('requisition1')])
|
||||
-
|
||||
I duplicate requisition.
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
self.copy(cr, uid, ref('requisition1'))
|
||||
-
|
||||
I delete requisition.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
self.unlink(cr, uid, [ref("requisition1")])
|
||||
|
|
@ -1,189 +1,89 @@
|
|||
|
||||
-
|
||||
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 create the procurement order and run that procurement.
|
||||
-
|
||||
I start by creating a new product 'Laptop ACER', which is purchased at Asustek, in MTO,
|
||||
with the generation of purchase requisitions.
|
||||
!python {model: make.procurement}: |
|
||||
context.update({'active_model':'product.product', 'active_ids': [ref('product.product_product_hdd3')], 'active_id': ref('product.product_product_hdd3')})
|
||||
-
|
||||
!record {model: product.product, id: product_product_laptopacer0}:
|
||||
categ_id: product.product_category_3
|
||||
cost_method: standard
|
||||
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
|
||||
min_qty: 1.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
!record {model: make.procurement, id: procurement_product_hdd3}:
|
||||
product_id: product.product_product_hdd3
|
||||
qty: 15
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
volume: 0.0
|
||||
warranty: 0.0
|
||||
weight: 0.0
|
||||
weight_net: 0.0
|
||||
list_price: 100.0
|
||||
warehouse_id: stock.stock_warehouse_shop0
|
||||
-
|
||||
Then I sell 5 Laptop ACER to the customer Agrolait, sale order TEST/TENDER/0001.
|
||||
!python {model: make.procurement}: |
|
||||
self.make_procurement(cr, uid, [ref('procurement_product_hdd3')], context)
|
||||
-
|
||||
!record {model: sale.order, id: sale_order_testtender0}:
|
||||
date_order: !eval time.strftime('%Y-%m-%d')
|
||||
invoice_quantity: order
|
||||
name: TEST/TENDER/0001
|
||||
order_line:
|
||||
- name: Laptop ACER
|
||||
price_unit: 100.0
|
||||
product_uom: product.product_uom_unit
|
||||
product_uom_qty: 5.0
|
||||
state: draft
|
||||
delay: 7.0
|
||||
product_id: product_product_laptopacer0
|
||||
product_uos_qty: 5.0
|
||||
th_weight: 0.0
|
||||
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 run the scheduler.
|
||||
-
|
||||
I confirm the sale order.
|
||||
!python {model: procurement.order}: |
|
||||
self.run_scheduler(cr, uid)
|
||||
-
|
||||
!workflow {model: sale.order, action: order_confirm, ref: sale_order_testtender0}
|
||||
I check requisition details which created after run procurement.
|
||||
-
|
||||
I launch the scheduler to compute all procurements, and specify all requisitions orders.
|
||||
!python {model: procurement.order}: |
|
||||
procurement_ids = self.search(cr, uid, [('requisition_id','!=', False)])
|
||||
for procurement in self.browse(cr, uid, procurement_ids, context=context):
|
||||
requisition = procurement.requisition_id
|
||||
assert requisition.date_end == procurement.date_planned, "End date is not correspond."
|
||||
assert len(requisition.line_ids) == 1, "Requisition Lines should be one."
|
||||
line = requisition.line_ids[0]
|
||||
assert line.product_id.id == procurement.product_id.id, "Product is not correspond."
|
||||
assert line.product_uom_id.id == procurement.product_uom.id, "UOM is not correspond."
|
||||
assert line.product_qty == procurement.product_qty, "Quantity is not correspond."
|
||||
-
|
||||
!python {model: procurement.order.compute.all}: |
|
||||
proc_obj = self.pool.get('procurement.order')
|
||||
proc_obj._procure_confirm(cr,uid)
|
||||
I open another requisition.
|
||||
-
|
||||
On the purchase requisition, I create a new purchase order for the supplier 'DistriPC' by clicking on
|
||||
the button 'New RfQ'. This opens a window to ask me the supplier and I set DistriPC .
|
||||
-
|
||||
!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.
|
||||
!python {model: purchase.requisition}: |
|
||||
self.tender_in_progress(cr, uid, [ref("requisition1")], context=context)
|
||||
-
|
||||
Supplier send one RFQ so I create requisition request of that supplier.
|
||||
-
|
||||
!python {model: purchase.requisition.partner}: |
|
||||
req_obj = self.pool.get('purchase.requisition')
|
||||
ids =req_obj.search(cr, uid, [('origin','=','Laptop ACER')])
|
||||
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], })
|
||||
|
||||
context.update({"active_model": "purchase.requisition","active_ids": [ref("requisition1")],"active_id": ref("requisition1")})
|
||||
-
|
||||
!record {model: purchase.requisition.partner, id: requisition_partner_0}:
|
||||
partner_id: base.res_partner_desertic_hispafuentes
|
||||
-
|
||||
!python {model: purchase.requisition.partner}: |
|
||||
self.create_order(cr, uid, [ref("requisition_partner_0")], context=context)
|
||||
-
|
||||
I check that I have two purchase orders on the purchase requisition.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
from tools.translate import _
|
||||
order_ids =self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
|
||||
ids=len(order_ids)
|
||||
assert(ids == 2), _('Purchase Order not Created')
|
||||
|
||||
-
|
||||
I set the purchase requisition as 'Not Exclusive'.
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
ids =self.search(cr, uid, [('origin','=','Laptop ACER')])
|
||||
self.write(cr,uid,ids[0],{'exclusive': 'multiple' })
|
||||
-
|
||||
I change the quantities so that the purchase order for DistriPC includes 3 pieces and the
|
||||
purchase order for Asustek includes 2 pieces.
|
||||
I check that the RFQ details which created for supplier.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
line_obj=self.pool.get('purchase.order.line')
|
||||
partner_obj=self.pool.get('res.partner')
|
||||
requistion_obj=self.pool.get('purchase.requisition')
|
||||
requistion_ids =requistion_obj.search(cr, uid, [('origin','=','Laptop ACER')])
|
||||
partner_id1=partner_obj.search(cr,uid,[('name','=','ASUStek')])[0]
|
||||
partner_id2=partner_obj.search(cr,uid,[('name','=','Distrib PC')])[0]
|
||||
purchase_id1= self.search(cr, uid, [('partner_id','=',partner_id1),('requisition_id','in',requistion_ids)])
|
||||
purchase_id2= self.search(cr, uid, [('partner_id','=',partner_id2),('requisition_id','in',requistion_ids)])
|
||||
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
|
||||
line_obj.write(cr, uid, order_line1, {'product_qty':2})
|
||||
line_obj.write(cr, uid, order_line2, {'product_qty':3})
|
||||
purchase_ids = self.search(cr, uid, [('requisition_id','=',ref("requisition1"))])
|
||||
assert purchase_ids, "RFQ is not created."
|
||||
rfq = self.browse(cr, uid, purchase_ids[0], context=context)
|
||||
requisition = rfq.requisition_id
|
||||
supplier = rfq.partner_id
|
||||
assert supplier.id == ref('base.res_partner_desertic_hispafuentes'), "RFQ Partner is not correspond."
|
||||
assert len(rfq.order_line) == len(requisition.line_ids), "Lines are not correspond."
|
||||
for rfq_line in rfq.order_line:
|
||||
for line in requisition.line_ids:
|
||||
if rfq_line.product_id.id == line.product_id.id:
|
||||
product = line.product_id
|
||||
uom_id = line.product_uom_id.id or False
|
||||
assert rfq_line.product_qty == line.product_qty, "Quantity is not correspond."
|
||||
assert rfq_line.product_uom.id == uom_id, "UOM is not correspond."
|
||||
-
|
||||
I confirm and validate both purchase orders.
|
||||
I confirmed RFQ which has best price.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
order_ids= self.search(cr, uid, [])
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in order_ids:
|
||||
wf_service.trg_validate(uid, 'purchase.order',id,'purchase_confirm', cr)
|
||||
wf_service.trg_validate(uid, 'purchase.order',id,'purchase_approve', cr)
|
||||
-
|
||||
I check that the delivery order of the customer is in state 'Waiting Goods'.
|
||||
-
|
||||
!python {model: stock.picking }: |
|
||||
from tools.translate import _
|
||||
picking_id = self.search(cr, uid, [('origin','=','TEST/TENDER/0001')])
|
||||
if picking_id:
|
||||
pick=self.browse(cr,uid,picking_id[0])
|
||||
assert (pick.state =='confirmed'),_('Picking is not in confirm state.')
|
||||
assert (pick.move_lines[0].state == 'waiting'), _('Stock Move is not Waiting state.')
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
purchase = self.browse(cr, uid, ref('rfq2'), context=context)
|
||||
wf_service.trg_validate(uid, 'purchase.order', purchase.id, 'purchase_confirm', cr)
|
||||
|
||||
-
|
||||
I receive the order of the supplier Asustek from the Incoming Products menu.
|
||||
I check status of requisition after confirmed best RFQ.
|
||||
-
|
||||
!python {model: stock.picking }: |
|
||||
import time
|
||||
partner_obj=self.pool.get('res.partner')
|
||||
order_obj=self.pool.get('purchase.order')
|
||||
partner_id=partner_obj.search(cr,uid,[('name','=','ASUStek')])[0]
|
||||
picking_id = self.search(cr, uid, [('address_id.partner_id','=',partner_id),('type','=','in')])
|
||||
if picking_id:
|
||||
pick=self.browse(cr,uid,picking_id[0])
|
||||
move =pick.move_lines[0]
|
||||
partial_datas = {
|
||||
'partner_id': pick.address_id.partner_id.id,
|
||||
'address_id': pick.address_id.id,
|
||||
'delivery_date' : time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
partial_datas['move%s'%(move.id)]= {
|
||||
'product_id': move.product_id.id,
|
||||
'product_qty': move.product_qty,
|
||||
'product_uom': move.product_uom.id,
|
||||
}
|
||||
self.do_partial(cr, uid, picking_id,partial_datas)
|
||||
!python {model: purchase.requisition}: |
|
||||
requisition = self.browse(cr, uid, ref('requisition1'), context=context)
|
||||
requisition.state == 'done', "Requisition should be closed."
|
||||
-
|
||||
I receive the order of the supplier DistriPC from the Incoming Shipments menu.
|
||||
-
|
||||
!python {model: stock.picking }: |
|
||||
import time
|
||||
partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
|
||||
picking_id = self.search(cr, uid, [('address_id.partner_id','=',partner_id),('type','=','in')])
|
||||
if picking_id:
|
||||
pick=self.browse(cr,uid,picking_id[0])
|
||||
move =pick.move_lines[0]
|
||||
partial_datas = {
|
||||
'partner_id':pick.address_id.partner_id.id,
|
||||
'address_id': pick.address_id.id,
|
||||
'delivery_date' : time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
partial_datas['move%s'%(move.id)]= {
|
||||
'product_id': move.product_id.id,
|
||||
'product_qty': move.product_qty,
|
||||
'product_uom': move.product_uom.id,
|
||||
}
|
||||
self.do_partial(cr, uid, picking_id,partial_datas)
|
||||
-
|
||||
I check that the delivery order of the customer is in the state Available.
|
||||
-
|
||||
!python {model: stock.picking }: |
|
||||
from tools.translate import _
|
||||
picking_id = self.search(cr, uid, [('origin','=','TEST/TENDER/0001'),('type','=','out')])
|
||||
if picking_id:
|
||||
pick=self.browse(cr,uid,picking_id[0])
|
||||
assert(pick.state == 'assigned'), _('Picking is not in available state')
|
||||
|
||||
I print a Requisition report
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
import netsvc, tools, os
|
||||
(data, format) = netsvc.LocalService('report.purchase.requisition').create(cr, uid, [ref('purchase_requisition.requisition1')], {}, {})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'purchase_requisition-purchase_requisition_report.'+format), 'wb+').write(data)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
-
|
||||
In order to test process of the purchase requisition ,I create requisition
|
||||
-
|
||||
!record {model: purchase.requisition, id: requisition1}:
|
||||
exclusive: exclusive
|
||||
line_ids:
|
||||
- product_id: product.product_product_cpu1
|
||||
product_qty: 10.0
|
||||
product_uom_id: product.product_uom_unit
|
||||
|
|
@ -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')
|
|
@ -1,8 +0,0 @@
|
|||
-
|
||||
In order to test the PDF reports defined on Purchase Requisition, we will print a Requisition report
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
import netsvc, tools, os
|
||||
(data, format) = netsvc.LocalService('report.purchase.requisition').create(cr, uid, [ref('purchase_requisition.order_purchase_requisition1')], {}, {})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'purchase_requisition-purchase_requisition_report.'+format), 'wb+').write(data)
|
|
@ -1,166 +0,0 @@
|
|||
-
|
||||
In order to test the purchase requisition flow,I start by creating a new product 'MOB1'
|
||||
-
|
||||
!record {model: product.product, id: product_product_mob1}:
|
||||
name: MOB1
|
||||
categ_id: product.product_category_3
|
||||
cost_method: standard
|
||||
mes_type: fixed
|
||||
price_margin: 2.0
|
||||
procure_method: make_to_stock
|
||||
property_stock_inventory: stock.location_inventory
|
||||
property_stock_procurement: stock.location_procurement
|
||||
property_stock_production: stock.location_production
|
||||
standard_price: 2000.0
|
||||
supply_method: buy
|
||||
type: product
|
||||
uom_id: product.product_uom_unit
|
||||
uom_po_id: product.product_uom_unit
|
||||
volume: 0.0
|
||||
warranty: 0.0
|
||||
weight: 0.0
|
||||
weight_net: 0.0
|
||||
-
|
||||
I create purchase requisition for MOB1 for 1 quantity.
|
||||
-
|
||||
!record {model: purchase.requisition, id: purchase_requisition_te0}:
|
||||
company_id: base.main_company
|
||||
exclusive: multiple
|
||||
line_ids:
|
||||
- company_id: base.main_company
|
||||
product_id: product_product_mob1
|
||||
product_qty: 10.0
|
||||
product_uom_id: product.product_uom_unit
|
||||
name: TE00009
|
||||
-
|
||||
Initially purchase requisition is in draft state.
|
||||
-
|
||||
!assert {model: purchase.requisition, id: purchase_requisition_te0}:
|
||||
- state == 'draft'
|
||||
-
|
||||
Copy purchase requisition which is in draft state than confirm and Done it.
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
copy_id = self.copy(cr, uid, ref("purchase_requisition_te0"))
|
||||
self.tender_cancel(cr, uid, [copy_id], context=None)
|
||||
self.tender_reset(cr, uid, [copy_id], context=None)
|
||||
self.tender_in_progress(cr, uid, [copy_id], context=None)
|
||||
self.tender_done(cr, uid, [copy_id], context=None)
|
||||
-
|
||||
I confirm the purchase requisition for MOB1.
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
self.tender_in_progress(cr, uid, [ref("purchase_requisition_te0")])
|
||||
-
|
||||
I check that the purchase requisition which was initially in the draft state has transmit to In Progress after confirm it.
|
||||
-
|
||||
!assert {model: purchase.requisition, id: purchase_requisition_te0}:
|
||||
- state == 'in_progress'
|
||||
-
|
||||
In order to create a purchase order for 'Axelor', i click on the wizard 'Request a Quotation' and create record for wizard.
|
||||
-
|
||||
!record {model: purchase.requisition.partner, id: purchase_requisition_partner_0}:
|
||||
partner_address_id: base.res_partner_address_3000
|
||||
partner_id: base.res_partner_desertic_hispafuentes
|
||||
-
|
||||
I click on 'Create Quotation' for creating PO.
|
||||
-
|
||||
!python {model: purchase.requisition.partner}: |
|
||||
self.create_order(cr, uid, [ref("purchase_requisition_partner_0")], {"active_model": "purchase.requisition",
|
||||
"active_ids": [ref("purchase_requisition_te0")],"active_id": ref("purchase_requisition_te0"), })
|
||||
-
|
||||
I confirm the purchase order of Axelor.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_id= self.search(cr, uid, [('requisition_id','=',ref("purchase_requisition_te0"))])
|
||||
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)
|
||||
-
|
||||
I check that Quotation of Axelor is Approved.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_id= self.search(cr, uid, [('requisition_id','=',ref("purchase_requisition_te0"))])[0]
|
||||
state=self.browse(cr,uid,purchase_id).state
|
||||
assert (state=='approved')
|
||||
-
|
||||
I click on Done button
|
||||
-
|
||||
!python {model: purchase.requisition}: |
|
||||
self.tender_done(cr, uid, [ref("purchase_requisition_te0")],)
|
||||
-
|
||||
I check that after click on Done button state is in done.
|
||||
-
|
||||
!assert {model: purchase.requisition, id: purchase_requisition_te0}:
|
||||
- state == 'done'
|
||||
-
|
||||
In order to test the purchase requisition flow for Requisition Type is exclusive
|
||||
-
|
||||
I create purchase requisition for Requisition Type is exclusive
|
||||
-
|
||||
!record {model: purchase.requisition, id: purchase_requisition_ex1}:
|
||||
company_id: base.main_company
|
||||
exclusive: exclusive
|
||||
line_ids:
|
||||
- company_id: base.main_company
|
||||
product_id: product_product_mob1
|
||||
product_qty: 10.0
|
||||
product_uom_id: product.product_uom_unit
|
||||
name: TE000010
|
||||
-
|
||||
I Create a First Purchase Order for the supplier 'Distrib PC'.
|
||||
-
|
||||
!record {model: purchase.requisition.partner, id: purchase_requisition_partner_1}:
|
||||
partner_address_id: base.res_partner_address_7
|
||||
partner_id: base.res_partner_4
|
||||
-
|
||||
I create Quotations For supplier 'Distrib PC'.
|
||||
-
|
||||
!python {model: purchase.requisition.partner}: |
|
||||
self.create_order(cr, uid, [ref("purchase_requisition_partner_1")], {"active_model": "purchase.requisition",
|
||||
"active_ids": [ref("purchase_requisition_ex1")],"active_id": ref("purchase_requisition_ex1"), })
|
||||
-
|
||||
I Create a Second Purchase Order for the supplier ASUStek.
|
||||
-
|
||||
!record {model: purchase.requisition.partner, id: purchase_requisition_partner_2}:
|
||||
partner_address_id: base.res_partner_address_tang
|
||||
partner_id: base.res_partner_asus
|
||||
-
|
||||
I create Quotations For supplier 'ASUStek'.
|
||||
-
|
||||
!python {model: purchase.requisition.partner}: |
|
||||
self.create_order(cr, uid, [ref("purchase_requisition_partner_2")], {"active_model": "purchase.requisition",
|
||||
"active_ids": [ref("purchase_requisition_ex1")],"active_id": ref("purchase_requisition_ex1"), })
|
||||
-
|
||||
I check that Initially purchase requisition is draft state.
|
||||
-
|
||||
!assert {model: purchase.requisition, id: purchase_requisition_ex1}:
|
||||
- state == 'draft'
|
||||
-
|
||||
I confirm the Second purchase order of ASUStek, than check that Quotation is Approved.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
purchase_id= self.search(cr, uid, [('partner_id','=',ref("base.res_partner_asus")),('requisition_id','=',ref("purchase_requisition_ex1"))])
|
||||
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)
|
||||
state=self.browse(cr,uid,purchase_id[0]).state
|
||||
assert (state=='approved')
|
||||
|
||||
-
|
||||
I check that Quotation of Distrib PC is cancelled.
|
||||
-
|
||||
!python {model: purchase.order}: |
|
||||
partner_id=self.pool.get('res.partner').search(cr,uid,[('name','=','Distrib PC')])[0]
|
||||
purchase_id= self.search(cr, uid, [('partner_id','=',partner_id),('requisition_id','=',ref("purchase_requisition_ex1"))])[0]
|
||||
state=self.browse(cr,uid,purchase_id).state
|
||||
assert (state=='cancel')
|
||||
-
|
||||
I check that Purchase Requisition is Done.
|
||||
-
|
||||
!assert {model: purchase.requisition, id: purchase_requisition_ex1}:
|
||||
- state == 'done'
|
|
@ -31,7 +31,7 @@ class purchase_requisition_partner(osv.osv_memory):
|
|||
_description = "Purchase Requisition Partner"
|
||||
_columns = {
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', required=True,domain=[('supplier', '=', True)]),
|
||||
'partner_address_id':fields.many2one('res.partner.address', 'Address', required=True),
|
||||
'partner_address_id':fields.many2one('res.partner.address', 'Address'),
|
||||
}
|
||||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
|
|
Loading…
Reference in New Issue