[IMP] improve project_mrp yml

bzr revid: ara@tinyerp.com-20111212134231-nqjycxwnpj5i812f
This commit is contained in:
ARA (OpenERP) 2011-12-12 19:12:31 +05:30
parent dce7b0bb00
commit 9f51a48391
3 changed files with 26 additions and 78 deletions

View File

@ -54,7 +54,7 @@ task is completed.
'depends': ['project', 'procurement', 'sale', 'mrp_jit'],
'init_xml': [],
'update_xml': ['project_mrp_workflow.xml', 'process/project_mrp_process.xml', 'project_mrp_view.xml'],
'demo_xml': [],
'demo_xml': ['project_mrp_demo.xml'],
'test': ['test/project_task_procurement.yml'],
'installable': True,
'active': False,

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<!--Resource: sale.order.line for services type product-->
<record id="line_services" model="sale.order.line">
<field name="order_id" ref="sale.order"/>
<field name="name">Partners Training</field>
<field name="product_id" ref="product_product_partnerstraining0"/>
<field name="product_uom" ref="product.uom_hour"/>
<field name="price_unit">1.0</field>
<field name="product_uom_qty">5.0</field>
<field name="type">make_to_order</field>
</record>
</data>
</openerp>

View File

@ -1,83 +1,13 @@
- |
In order to test project_mrp module with OpenERP I create a sale order
with product type 'service' so when procurement runs one task is created for
the project associated with my sale order.
-
I create record for a service type product.
In order to test process to generate task automatic from procurement, I confirm sale order.
-
!record {model: product.product, id: product_product_partnerstraining0, view: False}:
categ_id: product.product_category_7
cost_method: standard
mes_type: fixed
name: Partners Training
procure_method: make_to_order
supply_method: produce
type: service
uom_id: product.uom_day
uom_po_id: product.uom_day
warranty: 0.0
- |
I create a sale order for product Partners Training which has type 'Service',
and select the appropriate Analytic Account matching my project.
-
!record {model: sale.order, id: sale_order_so0}:
date_order: !eval time.strftime('%Y-%m-%d')
invoice_quantity: order
name: TESTSO006
order_policy: manual
partner_id: base.res_partner_asus
partner_invoice_id: base.res_partner_address_tang
partner_order_id: base.res_partner_address_tang
partner_shipping_id: base.res_partner_address_tang
order_line:
- state: draft
delay: 7.0
name: Partners Training
price_unit: 1.0
product_id: product_product_partnerstraining0
product_uom: product.uom_day
product_uom_qty: 5.0
type: make_to_order
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
user_id: base.user_demo
- I select the Analytic Account for my project on the sale order
-
!python {model: sale.order}: |
acc_id = self.pool.get('project.project').browse(cr, uid,
ref('project.project_integrate_openerp')).analytic_account_id.id
self.write(cr, uid, ref('sale_order_so0'), {'project_id': acc_id})
-
I confirm this sale order.
-
!workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
-
I check the procurements.
-
!python {model: procurement.order}: |
orderline_obj = self.pool.get('sale.order.line')
line_ids = orderline_obj.search(cr, uid, [('order_id','=', ref('sale_order_so0'))])
orders = orderline_obj.browse(cr, uid, line_ids)
proc_ids = map(lambda x: x.procurement_id.id, orders)
assert proc_ids, 'No Procurements!'
-
The scheduler runs.
-
!function {model: procurement.order, name: run_scheduler}:
- model: procurement.order
search: "[]"
!workflow {model: sale.order, action: order_confirm, ref: sale.order}
-
Now I check that one task is created for my sale order, in the desired project
-
!python {model: project.task}: |
order_obj = self.pool.get('sale.order')
order = order_obj.browse(cr, uid, ref('sale_order_so0'))
# planned_hours == 40 because default company project UOM is hours, and
# product was sold as 5.0 days.
task_id = self.search(cr, uid, [('name', '=', order.name+":Partners Training"),
('project_id','=', ref('project.project_integrate_openerp')),
('planned_hours','=', 40.0),
('state','=','draft')])
assert task_id, 'Expected Task not found!'
task_id = self.search(cr, uid, [('sale_line_id', '=', ref('line_services'))])
task_rec = self.browse(cr, uid, task_id[0])
assert task_id, 'Expected Task not found!'
assert task_rec.planned_hours, 'Expected hour not found!'
assert task_rec.date_deadline, 'Expected task deadline not found!'