From f68434aec96122db34242f96aca040f782d56bf7 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 15 Nov 2011 19:12:14 +0100 Subject: [PATCH] [IMP] project_mrp: improve test to verify project/task assignation This is done in prevision of a pending change to refactor the way project_mrp module hooks onto the sale module. bzr revid: odo@openerp.com-20111115181214-fhpyotvp22s0iq06 --- .../test/project_task_procurement.yml | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/addons/project_mrp/test/project_task_procurement.yml b/addons/project_mrp/test/project_task_procurement.yml index faf99dc5419..b2cc6a68363 100644 --- a/addons/project_mrp/test/project_task_procurement.yml +++ b/addons/project_mrp/test/project_task_procurement.yml @@ -1,10 +1,11 @@ -- - In order to test project_mrp module with OpenERP I want to create sale orders - with product type 'service' so when procurement runs one task is created. +- | + 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. - - !record {model: product.product, id: product_product_partnerstraining0}: + !record {model: product.product, id: product_product_partnerstraining0, view: False}: categ_id: product.product_category_7 cost_method: standard mes_type: fixed @@ -15,8 +16,9 @@ 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'. +- | + 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') @@ -40,6 +42,13 @@ 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. - @@ -60,11 +69,15 @@ - model: procurement.order search: "[]" - - Now I check that one task is created for my 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')) - task_id = self.search(cr, uid, [('name','like', order.name)]) - assert task_id, 'No Task is created!' - + 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!' \ No newline at end of file