[ADD] project_mrp: Added a yaml.
authoruco (OpenERP) <uco@tinyerp.com>
Fri, 21 May 2010 09:13:08 +0000 (14:43 +0530)
committeruco (OpenERP) <uco@tinyerp.com>
Fri, 21 May 2010 09:13:08 +0000 (14:43 +0530)
bzr revid: uco@tinyerp.com-20100521091308-00b8v8fenysdtc7s

addons/project_mrp/__openerp__.py
addons/project_mrp/test/project_task_procurement.yml [new file with mode: 0644]

index ee5a942..342ff9e 100644 (file)
@@ -53,6 +53,7 @@ automatically created via sale orders.
                    #'process/project_mrp_process.xml',
                    ],
     'demo_xml': [],
+    'test': ['test/project_task_procurement.yml'],
     'installable': True,
     'active': False,
     'certificate': '0031976495453',
diff --git a/addons/project_mrp/test/project_task_procurement.yml b/addons/project_mrp/test/project_task_procurement.yml
new file mode 100644 (file)
index 0000000..dda382a
--- /dev/null
@@ -0,0 +1,75 @@
+-
+  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.
+-
+  I create record for a service type product.
+-
+  !record {model: product.product, id: product_product_partnerstraining0}:
+    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'.
+- 
+  !record {model: sale.order, id: sale_order_so0}:
+    date_order: '2010-05-21'
+    invoice_quantity: order
+    name: SO006
+    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
+        th_weight: 0.0
+        type: make_to_order
+    picking_policy: direct
+    pricelist_id: product.list0
+    shop_id: sale.shop
+    user_id: base.user_demo
+-
+  I confirm this sale order.
+-
+  !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
+-
+  I check the procurements.
+-
+  !python {model: mrp.procurement}: |
+    from tools.translate import _
+    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: mrp.procurement, name: run_scheduler}:
+    - model: mrp.procurement
+      search: "[('state','=','confirmed')]"
+-
+  Now I check the tasks.
+-
+  I see that one task is created for my sale order.
+-
+  !python {model: project.task}: |
+    from tools.translate import _
+    order_obj = self.pool.get('sale.order')
+    order = order_obj.browse(cr, uid, ref('sale_order_so0')) 
+    task_id = self.search(cr, uid, [('project_id.name','=', order.name)]) 
+    assert task_id, _('No Task is created!')
+    
\ No newline at end of file