[ADD]: mrp: Added new yml test to partial consumption and production + scapping compo...
authorRucha (Open ERP) <rpa@tinyerp.com>
Thu, 3 Nov 2011 06:59:03 +0000 (12:29 +0530)
committerRucha (Open ERP) <rpa@tinyerp.com>
Thu, 3 Nov 2011 06:59:03 +0000 (12:29 +0530)
bzr revid: rpa@tinyerp.com-20111103065903-kzuvb5y5ypdr5opz

addons/mrp/__openerp__.py
addons/mrp/test/production_order_consume.yml [new file with mode: 0644]

index 6a475c5..49b6200 100644 (file)
@@ -93,6 +93,7 @@ Dashboard provided by this module:
     ],
     'test': [
          'test/mrp_production_order.yml',
+         'test/production_order_consume.yml', 
          'test/mrp_packs.yml',
          'test/mrp_production_cancel.yml',
          'test/mrp_report.yml',
diff --git a/addons/mrp/test/production_order_consume.yml b/addons/mrp/test/production_order_consume.yml
new file mode 100644 (file)
index 0000000..a5c4b3e
--- /dev/null
@@ -0,0 +1,77 @@
+-
+  I create production order of 5 KIT Shelf of 100cm to test partial consumption and production.
+-
+  !record {model: mrp.production, id: mrp_production_mo3}:
+    company_id: base.main_company
+    date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
+    location_dest_id: stock.stock_location_stock
+    location_src_id: stock.stock_location_stock
+    product_id: product.product_product_kitshelfofcm0
+    product_qty: 5.0
+    product_uom: product.product_uom_unit
+    product_uos_qty: 5.0
+-
+  I confirm the manufacturing order.
+-
+  !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo3}
+-
+  The production order is Waiting Goods, so I force reservation of components.
+-
+ !python {model: mrp.production}:
+  self.force_production(cr, uid, [ref("mrp_production_mo3")])
+-
+  I mark KIT Shelf is in production.
+-
+  !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo3}
+-
+  I Consume 4 Side Panels first and scrap one damaged Side Panel.
+-
+  !python {model: mrp.production}: |
+    production = self.browse(cr, uid, ref("mrp_production_mo3"))
+    move_ids = [move for move in production.move_lines if move.product_id.id == ref('product.product_product_sidepanel0')]
+    if move_ids:
+      move = move_ids[0]
+      move.action_consume(4.0)
+      scrap_location_ids = self.pool.get('stock.location').search(cr, uid, [('scrap_location','=',True)])
+      if scrap_location_ids:  
+        move.action_scrap(1.0, scrap_location_ids[0])
+-
+  I produce 2.0 KIT Shelves.
+-
+  !python {model: mrp.product.produce}: |
+    context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo3")], "tz": False, "active_id":ref('mrp_production_mo3')}
+    wiz_id = self.create(cr, uid, {'mode': 'consume_produce', 'product_qty': 2.0}, context=context)
+    self.do_produce(cr, uid, [wiz_id], context=context)
+-
+  I check there will be 2.0 KIT Shelves in Finished Products.
+-
+  !python {model: mrp.production}: |
+    production = self.browse(cr, uid, ref("mrp_production_mo3"))
+    move_ids = [move for move in production.move_created_ids2 if move.product_id.id == ref('product.product_product_kitshelfofcm0')]
+    if move_ids:
+      assert move_ids[0].product_qty == 2.0
+-
+  Now I consume remaining components for production of KIT Shelves.
+-
+  !python {model: mrp.product.produce}: |
+    context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo3")], "tz": False, "active_id":ref('mrp_production_mo3')}
+    wiz_id = self.create(cr, uid, {'mode': 'consume'}, context=context)
+    self.do_produce(cr, uid, [wiz_id], context=context)
+-
+  I check there is nothing remaining in Products to Consume.
+-
+  !python {model: mrp.production}: |
+    production = self.browse(cr, uid, ref("mrp_production_mo3"))
+    assert len(production.move_lines) == 0
+-
+  Now I produce remaining 3.0 KIT Shelves.
+-
+  !python {model: mrp.product.produce}: |
+    context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo3")], "tz": False, "active_id":ref('mrp_production_mo3')}
+    wiz_id = self.create(cr, uid, {'mode': 'consume_produce'}, context=context)
+    self.do_produce(cr, uid, [wiz_id], context=context)
+-
+  I check now the production order for 5.0 KIT Shelves is done.
+-
+  !assert {model: mrp.production, id: mrp_production_mo3}:
+    - state == 'done'