From 0e21615141f8e40977363969723d54992b8bfa8d Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Tue, 11 Oct 2011 16:49:12 +0530 Subject: [PATCH 01/44] [IMP]: mrp: Improvement in yml test cases to reflact proper business flow [WORK IN PROGRESS] bzr revid: rpa@tinyerp.com-20111011111912-dc8b8rwymxcf9l24 --- addons/mrp/test/mrp_production_order.yml | 49 ++++++++---------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/addons/mrp/test/mrp_production_order.yml b/addons/mrp/test/mrp_production_order.yml index c765809af1e..3a17cd2da70 100644 --- a/addons/mrp/test/mrp_production_order.yml +++ b/addons/mrp/test/mrp_production_order.yml @@ -1,9 +1,7 @@ - - In order to test the manufacturing order working with procurements I will use - some products with different supply method and procurement method, also check - the bills of material for the products. + In order to test the manufacturing order working with procurements I will create manufacturing orders of products having different configuration and check the flow. - - I am creating one manufacturing order. + I am creating a manufacturing order of 5 PC1-Basic PC which has 'Assembly Basic PC' as its BOM. - !record {model: mrp.production, id: mrp_production_mo1}: company_id: base.main_company @@ -11,59 +9,42 @@ location_dest_id: stock.stock_location_stock location_src_id: stock.stock_location_stock product_id: product.product_product_pc1 - name: MO/0123 product_qty: 5.0 product_uom: product.product_uom_unit - product_uos_qty: 0.0 + product_uos_qty: 5.0 - - I compute the data. + I click on the "Compute Data" to compute work center and scheduled product. - !python {model: mrp.production}: | self.action_compute(cr, uid, [ref("mrp_production_mo1")]) - - I confirm the order. + I confirm the manufacturing order for 5 PC1. - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1} - - I create record for changing production quantity to 6.00 + I check there is an internal picking for this MO to bring components in Raw Materials Location. +- + !python {model: mrp.production}: | + from tools.translate import _ + pick_ids = self.browse(cr, uid, ref("mrp_production_mo1")) + assert pick_ids.picking_id.id, _('No Internal Picking created for this manufacturing order!') +- + I remembered that we have to produce 6 PC1, so I create record for wizard 'Change Qty' changing production quantity to 6.00 - !record {model: change.production.qty, id: mrp_production_qty}: product_qty: 6.0 - - Changes the Quantity of Product. + I Approve change qty wizard for 6.00 PC1. - !python {model: change.production.qty}: | context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')} - self.default_get(cr, uid, ["product_qty"], context) self.change_prod_qty(cr, uid, [ref("mrp_production_qty")], context=context) - - I check now quantity of the production order is 6 or not. -- - !assert {model: mrp.production, id: mrp_production_mo1}: - - product_qty == 6 -- - I am checking Procurement orders for components of PC1. -- - !python {model: procurement.order}: | - from tools.translate import _ - production_obj = self.pool.get('mrp.production') - production = production_obj.browse(cr, uid, ref('mrp_production_mo1')) - product_ids = map(lambda x:x.product_id.id, production.move_lines) - proc_ids = self.search(cr, uid, [('product_id','in',product_ids)]) - assert proc_ids, _('No Procurements!') -- - The scheduler runs. + I compute the scheduler to procure the components based on their supply method. - !function {model: procurement.order, name: run_scheduler}: - model: procurement.order search: "[]" -- - I am checking Internal picking. -- - !python {model: stock.picking}: | - from tools.translate import _ - pick_ids = self.search(cr, uid, [('type','=','internal')]) - assert pick_ids, _('No Internal Pickings!') - I see that there is a manufacturing order for the sub product CPU_GEN with ready state and I start production of it. - From c8ac636b4cc9e28d15a69c20343abf1988207ac3 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Tue, 11 Oct 2011 17:02:08 +0530 Subject: [PATCH 02/44] [FIX]: mrp: typo bzr revid: rpa@tinyerp.com-20111011113208-jybutitnssxqu20l --- addons/mrp/test/mrp_production_order.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/test/mrp_production_order.yml b/addons/mrp/test/mrp_production_order.yml index 3a17cd2da70..fdf44c079c1 100644 --- a/addons/mrp/test/mrp_production_order.yml +++ b/addons/mrp/test/mrp_production_order.yml @@ -13,7 +13,7 @@ product_uom: product.product_uom_unit product_uos_qty: 5.0 - - I click on the "Compute Data" to compute work center and scheduled product. + I click on the "Compute Data" to compute work centre and scheduled product. - !python {model: mrp.production}: | self.action_compute(cr, uid, [ref("mrp_production_mo1")]) From 22813d4b41e4758509fdb3a8db5d689e93600f2a Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Wed, 12 Oct 2011 12:29:12 +0530 Subject: [PATCH 03/44] [IMP]: mrp: Improvement in yml test cases for proper business flow, completed mrp_production_order.yml bzr revid: rpa@tinyerp.com-20111012065912-eay72cxudeazpfjg --- addons/mrp/test/mrp_production_order.yml | 35 +++++++++++------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/addons/mrp/test/mrp_production_order.yml b/addons/mrp/test/mrp_production_order.yml index fdf44c079c1..d24cbf5bc69 100644 --- a/addons/mrp/test/mrp_production_order.yml +++ b/addons/mrp/test/mrp_production_order.yml @@ -9,6 +9,7 @@ location_dest_id: stock.stock_location_stock location_src_id: stock.stock_location_stock product_id: product.product_product_pc1 + name: MO/0123 product_qty: 5.0 product_uom: product.product_uom_unit product_uos_qty: 5.0 @@ -29,12 +30,12 @@ pick_ids = self.browse(cr, uid, ref("mrp_production_mo1")) assert pick_ids.picking_id.id, _('No Internal Picking created for this manufacturing order!') - - I remembered that we have to produce 6 PC1, so I create record for wizard 'Change Qty' changing production quantity to 6.00 + I remembered that we have to produce 6 PC1 instead of 5.0, so I create record for wizard 'Change Qty' changing production quantity to 6.0 - !record {model: change.production.qty, id: mrp_production_qty}: product_qty: 6.0 - - I Approve change qty wizard for 6.00 PC1. + I Approve change qty wizard for 6.0 PC1. - !python {model: change.production.qty}: | context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')} @@ -50,51 +51,47 @@ - !python {model: mrp.production}: | from tools.translate import _ - order_ids = self.search(cr, uid, [('state','=','ready'), ('product_id', '=', ref('product.product_product_cpu_gen'))]) - assert order_ids, _('No manufacturing order in Ready state!') + order_ids = self.search(cr, uid, [('state','=','ready'), ('product_id', '=', ref('product.product_product_cpu_gen')), ('origin', 'ilike', '%MO/0123%')]) + assert order_ids, _('No manufacturing order in Ready state for CPU_GEN!') import netsvc wf_service = netsvc.LocalService("workflow") for order in order_ids: wf_service.trg_validate(uid, 'mrp.production', order, 'button_produce', cr) - - I create record for producing products with quantity 6.00. + Now to produce CPU_GEN, I create record of wizard 'Consume & Produce' with quantity 6.0. - !record {model: mrp.product.produce, id: mrp_product_produce0}: - product_qty: 6.00 + product_qty: 6.0 mode: 'consume_produce' - - I produce the product. + I confirm the production of 6.0 CPU_GEN. - !python {model: mrp.product.produce}: | prod_obj = self.pool.get('mrp.production') prod_ids = prod_obj.search(cr, uid, [('state','=','in_production'), ('product_id', '=', ref('product.product_product_cpu_gen'))]) self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids}) - - Now the manufacturing order for subproduct CPU_GEN is done and manufacturing - order for PC1 is in ready state. + Component CPU_GEN is produced and now manufacturing order for PC1 is ready to produce. - - !python {model: mrp.production}: | - from tools.translate import _ - prod_ids = self.search(cr, uid, [('state','=','done'), ('product_id', '=', ref('product.product_product_cpu_gen'))]) - assert prod_ids, _('Manufacturing order for CPU_GEN is yet not done!') + !assert {model: mrp.production, id: mrp_production_mo1}: + - state == 'ready' - - I start producing the product PC1. + I start production of PC1. - !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo1} - - I create record for producing products with quantity 6.00. + I create record for producing products with quantity 6.0. - - !record {model: mrp.product.produce, id: mrp_product_produce1}: - product_qty: 6.00 + !record {model: mrp.product.produce, id: mrp_product_produce1, context: "{'active_id': ref('mrp_production_mo1')}"}: mode: 'consume_produce' - - Finally my production order is done. + I produce the products by clicking on 'Produce' - !python {model: mrp.product.produce}: | context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')} self.do_produce(cr, uid, [ref('mrp_product_produce1')], context=context) - - I check now the production order for PC1 is done. + I check now the production order for 6.0 PC1 is done. - !assert {model: mrp.production, id: mrp_production_mo1}: - state == 'done' From ab9a47b96e0d3596b6174fda0e7f7813fc9b3ce6 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Thu, 13 Oct 2011 17:10:17 +0530 Subject: [PATCH 04/44] [IMP]: mrp: Commented some yml files that are not properly formed to fulfill functionalities needed bzr revid: rpa@tinyerp.com-20111013114017-qsm5qlvn9m2od2vb --- addons/mrp/__openerp__.py | 7 +++---- addons/mrp/test/mrp_phantom_bom.yml | 5 +++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/mrp/__openerp__.py b/addons/mrp/__openerp__.py index b7b97aef158..ce09b621b98 100644 --- a/addons/mrp/__openerp__.py +++ b/addons/mrp/__openerp__.py @@ -93,13 +93,12 @@ Dashboard provided by this module: 'mrp_demo.xml', ], 'test': [ - 'test/mrp_procurement.yml', - 'test/mrp_packs.yml', - 'test/mrp_phantom_bom.yml', 'test/mrp_production_order.yml', + 'test/mrp_packs.yml', 'test/mrp_production_cancel.yml', 'test/mrp_report.yml', - +# 'test/mrp_procurement.yml', +# 'test/mrp_phantom_bom.yml', ], 'installable': True, 'active': False, diff --git a/addons/mrp/test/mrp_phantom_bom.yml b/addons/mrp/test/mrp_phantom_bom.yml index 41f1920dc2d..5316102689c 100644 --- a/addons/mrp/test/mrp_phantom_bom.yml +++ b/addons/mrp/test/mrp_phantom_bom.yml @@ -1,3 +1,8 @@ +- + I think this file is not needed as its wasting lots of useless code in creating product, phantom bom and MOs, + the way is not right to check functionality of phantom bom, its better used in mrp_packs.yml file. + also we can use product SHE100KIT BOM of demo instead of creating all new datas. + - In order to test the mrp phantom bom type in OpenERP, I will create products and then I will create Phantom bom structure for those products. From d76aba76cf050aba77943eeb8318eaf1f7660156 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Thu, 13 Oct 2011 17:14:45 +0530 Subject: [PATCH 05/44] [IMP, REM]: mrp: Improvement in test cases of mrp_packs.yml: * Removed creation of data in yml and taken reference of existing demo for ease bzr revid: rpa@tinyerp.com-20111013114445-iuy711bmmuzlr780 --- addons/mrp/test/mrp_packs.yml | 82 ++++------------------------------- 1 file changed, 8 insertions(+), 74 deletions(-) diff --git a/addons/mrp/test/mrp_packs.yml b/addons/mrp/test/mrp_packs.yml index 800d4f56476..b5c4065652e 100644 --- a/addons/mrp/test/mrp_packs.yml +++ b/addons/mrp/test/mrp_packs.yml @@ -1,72 +1,7 @@ - - In order to test the Packs in OpenERP, we will try to sell a "Pack of 24 - beers" which is composed of 24 "Beers" and a "Beers Pack". + In order to test the Packs in OpenERP, we will try to sell a "KIT Shelf of 100cm" which is composed of "[PROFIL] Assembly Section" and "[SIDEPAN] Side Panel" having Phantom BOM. - - I start by creating the Beers product. -- - !record {model: product.product, id: product_product_beers0}: - categ_id: product.cat1 - name: Beers - procure_method: make_to_stock - seller_ids: - - delay: 1 - name: base.res_partner_agrolait - min_qty: 2.0 - supply_method: buy - type: product - uom_id: product.product_uom_unit - uom_po_id: product.product_uom_unit -- - I create the "Beers Pack" product. -- - !record {model: product.product, id: product_product_beerspack0}: - categ_id: product.cat1 - name: Beers Pack - procure_method: make_to_stock - seller_ids: - - delay: 1 - name: base.res_partner_asus - min_qty: 2.0 - supply_method: buy - type: product - uom_id: product.product_uom_unit - uom_po_id: product.product_uom_unit -- - I create the "Pack of 24 beers" product -- - !record {model: product.product, id: product_product_packofbeers0}: - categ_id: product.cat1 - name: Pack of 24 Beers - procure_method: make_to_order - supply_method: produce - type: product - uom_id: product.product_uom_unit - uom_po_id: product.product_uom_unit -- - I define the Phantom Bill of Material for the "Pack of 24 beers" -- - !record {model: mrp.bom, id: mrp_bom_packofbeers0}: - bom_lines: - - company_id: base.main_company - name: Beers - product_id: product_product_beers0 - product_qty: 24.0 - product_uom: product.product_uom_unit - type: normal - - company_id: base.main_company - name: Beers Pack - product_id: product_product_beerspack0 - product_qty: 1.0 - product_uom: product.product_uom_unit - type: normal - name: Pack of 24 Beers - product_id: product_product_packofbeers0 - product_qty: 1.0 - product_uom: product.product_uom_unit - type: phantom -- - As all my data are created, I will create an outgoing order picking for a - "Pack of 24 Beers" + As all my data are already available, I will create an outgoing order picking for 2 "KIT Shelf of 100cm" - !record {model: stock.picking, id: picking_out}: address_id: base.res_partner_address_tang @@ -76,8 +11,8 @@ - company_id: base.main_company location_dest_id: stock.stock_location_customers location_id: stock.stock_location_stock - name: Pack of 24 Beers - product_id: product_product_packofbeers0 + name: KIT Shelf of 100cm + product_id: product.product_product_kitshelfofcm0 product_qty: 2.0 product_uom: product.product_uom_unit move_type: direct @@ -91,13 +26,12 @@ "active_id": ref("stock.menu_action_picking_tree"), } ) - - I check that my Picking of a "Pack of 24 beers" has been automatically - converted to a picking of 24 beers and a pack of beer, so that my - stock of beers remains exact. + I check that my Picking of "KIT Shelf of 100cm" has been automatically + converted to a picking of "[PROFIL] Assembly Section" and "[SIDEPAN] Side Panel". - !assert {model: stock.picking, id: picking_out, string: pack_of_beer_splitted}: - len(move_lines) >= 2 - move_lines[0].product_id.id <> move_lines[1].product_id.id - - move_lines[0].product_id.id in (ref('product_product_beers0'), ref('product_product_beerspack0')) - - move_lines[1].product_id.id in (ref('product_product_beers0'), ref('product_product_beerspack0')) + - move_lines[0].product_id.id in (ref('product.product_product_assemblysection0'), ref('product.product_product_sidepanel0')) + - move_lines[1].product_id.id in (ref('product.product_product_assemblysection0'), ref('product.product_product_sidepanel0')) From 45b4dab1e6b698d1ff43595762f2ff49dffc98ea Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Fri, 14 Oct 2011 16:22:59 +0530 Subject: [PATCH 06/44] [REM]: mrp: Removed some yml files which were having lots of code to create record rather than to test the real flow bzr revid: rpa@tinyerp.com-20111014105259-87ggqqoj3mmm0glp --- addons/mrp/test/mrp_phantom_bom.yml | 280 ---------------------------- addons/mrp/test/mrp_procurement.yml | 278 --------------------------- 2 files changed, 558 deletions(-) delete mode 100644 addons/mrp/test/mrp_phantom_bom.yml delete mode 100644 addons/mrp/test/mrp_procurement.yml diff --git a/addons/mrp/test/mrp_phantom_bom.yml b/addons/mrp/test/mrp_phantom_bom.yml deleted file mode 100644 index 5316102689c..00000000000 --- a/addons/mrp/test/mrp_phantom_bom.yml +++ /dev/null @@ -1,280 +0,0 @@ -- - I think this file is not needed as its wasting lots of useless code in creating product, phantom bom and MOs, - the way is not right to check functionality of phantom bom, its better used in mrp_packs.yml file. - also we can use product SHE100KIT BOM of demo instead of creating all new datas. - -- - In order to test the mrp phantom bom type in OpenERP, I will create products - and then I will create Phantom bom structure for those products. -- - I create BOM category fluid for Orange Juice -- - !record {model: product.uom.categ, id: product_uom_categ_fluid}: - name: Fluid -- - I create the products required to produce some orange juices with Oranges, Sugar and Water. -- - !record {model: product.uom, id: product_uom_litre0}: - category_id: product_uom_categ_fluid - factor: 1.0 - name: Litre - rounding: 0.01 -- - I create record for product Orange Juice. -- - !record {model: product.product, id: product_product_orangejuice0}: - categ_id: product.cat1 - name: Orange Juice - procure_method: make_to_order - supply_method: produce - type: product - uom_id: product_uom_litre0 - uom_po_id: product_uom_litre0 - property_stock_inventory: stock.location_inventory - property_stock_procurement: stock.location_procurement - property_stock_production: stock.location_production -- - I create record for product Orange. -- - !record {model: product.product, id: product_product_orange0}: - categ_id: product.cat1 - name: Orange - procure_method: make_to_stock - seller_ids: - - delay: 1 - name: base.res_partner_asus - min_qty: 1.0 - product_uom: product.product_uom_kgm - supply_method: buy - type: product - uom_id: product.product_uom_kgm - uom_po_id: product.product_uom_kgm - property_stock_inventory: stock.location_inventory - property_stock_procurement: stock.location_procurement - property_stock_production: stock.location_production -- - I create record for product Sugar. -- - !record {model: product.product, id: product_product_sugar0}: - categ_id: product.cat1 - name: Sugar - procure_method: make_to_stock - seller_ids: - - delay: 1 - name: base.res_partner_desertic_hispafuentes - min_qty: 2.0 - product_uom: product.product_uom_kgm - supply_method: buy - type: product - uom_id: product.product_uom_kgm - uom_po_id: product.product_uom_kgm - property_stock_inventory: stock.location_inventory - property_stock_procurement: stock.location_procurement - property_stock_production: stock.location_production -- - I create record for product Water. -- - !record {model: product.product, id: product_product_water0}: - categ_id: product.cat1 - name: Water - procure_method: make_to_order - seller_ids: - - delay: 1 - name: base.res_partner_agrolait - product_uom: product_uom_litre0 - min_qty: 2.0 - supply_method: buy - type: consu - uom_id: product_uom_litre0 - uom_po_id: product_uom_litre0 - property_stock_inventory: stock.location_inventory - property_stock_procurement: stock.location_procurement - property_stock_production: stock.location_production -- - I define the BoM to produce an orange juice. -- - !record {model: mrp.bom, id: mrp_bom_orangejuice0}: - company_id: base.main_company - name: Orange Juice - product_efficiency: 1.0 - product_id: product_product_orangejuice0 - product_qty: 1.0 - product_uom: product_uom_litre0 - type: phantom -- - changes UOM and name if product change. -- - !python {model: mrp.bom}: | - production_id = self.browse(cr, uid, [ref('mrp_bom_orangejuice0')], context=context)[0] - self.onchange_product_id(cr, uid, [ref('mrp_bom_orangejuice0')], production_id.product_id.id, False) -- - I create bom lines for BoM for Orange Juice. -- - !record {model: mrp.bom, id: mrp_bom_orangejuice0}: - bom_lines: - - bom_id: mrp_bom_orangejuice0 - company_id: base.main_company - name: Orange - product_efficiency: 1.0 - product_id: product_product_orange0 - product_qty: 0.5 - product_uom: product.product_uom_kgm - type: normal - - bom_id: mrp_bom_orangejuice0 - company_id: base.main_company - name: Sugar - product_efficiency: 1.0 - product_id: product_product_sugar0 - product_qty: 0.02 - product_uom: product.product_uom_kgm - type: normal - - bom_id: mrp_bom_orangejuice0 - company_id: base.main_company - name: Water - product_efficiency: 1.0 - product_id: product_product_water0 - product_qty: 0.80000000000000004 - product_uom: product_uom_litre0 - type: normal -- - I define Minimum stock rules for my stockable product "Orange". -- - !record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}: - company_id: base.main_company - location_id: stock.stock_location_stock - logic: max - name: OP/00002 - product_id: product_product_orange0 - product_max_qty: 10.0 - product_min_qty: 5.0 - product_uom: product.product_uom_kgm - qty_multiple: 1 - warehouse_id: stock.warehouse0 -- - I define Minimum stock rules for my stockable product "Sugar". -- - !record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op1}: - company_id: base.main_company - location_id: stock.stock_location_stock - logic: max - name: OP/00003 - product_id: product_product_sugar0 - product_max_qty: 4.0 - product_min_qty: 2.0 - product_uom: product.product_uom_kgm - qty_multiple: 1 - warehouse_id: stock.warehouse0 -- - I want to produce 100 litres of Orange juice. I am creating a manufacturing order for this. - I want to see how much quantities of sub products I need, to produce the Orange juice. -- - I compute the data. I get the bill of material of Orange juice and list of - scheduled products according to my bom. -- - !record {model: mrp.production, id: mrp_production_mo0}: - company_id: base.main_company - date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S") - location_dest_id: stock.stock_location_output - location_src_id: stock.stock_location_stock - product_id: product_product_orangejuice0 - product_qty: 100.0 - product_uom: product_uom_litre0 -- - Creating an mrp.production record. Computing Bills of materials. -- - !record {model: mrp.production, id: mrp_production_mo0}: - bom_id: mrp.mrp_bom_orangejuice0 - company_id: base.main_company - date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S") - location_dest_id: stock.stock_location_output - location_src_id: stock.stock_location_stock - name: MO/00002 - product_id: mrp.product_product_orangejuice0 - product_lines: - - name: Orange - product_id: mrp.product_product_orange0 - product_qty: 50.0 - product_uom: product.product_uom_kgm - production_id: mrp_production_mo0 - - name: Sugar - product_id: mrp.product_product_sugar0 - product_qty: 2.0 - product_uom: product.product_uom_kgm - production_id: mrp_production_mo0 - - name: Water - product_id: mrp.product_product_water0 - product_qty: 80.0 - product_uom: mrp.product_uom_litre0 - production_id: mrp_production_mo0 - product_qty: 100.0 - product_uom: mrp.product_uom_litre0 -- - I confirm the order. -- - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo0} -- - I am checking Procurement orders. There are 3 orders generated for Oranges, Sugar and Water. -- - !python {model: procurement.order}: | - proc_ids = self.search(cr, uid, [('product_id','in',[ref('product_product_orange0'),ref('product_product_sugar0'),ref('product_product_water0')])]) - assert proc_ids, 'No Procurements!' -- - The scheduler runs. -- - !function {model: procurement.order, name: run_scheduler}: - - model: procurement.order - search: "[]" -- - I am checking Internal picking. I see one picking for Orange juice and its - stock moves for Oranges, Sugar and Water made correctly. -- - !python {model: stock.picking}: | - pick_ids = self.search(cr, uid, [('type','=','internal')]) - assert pick_ids, 'No Internal Pickings!' -- - According to minimum stock rules. I have 2 purchase orders for - Sugar with 6 Kg from Axelor and Orange 60 Kg from ASUStek. -- - I confirm the purchase order of Sugar and Orange. -- - !python {model: purchase.order}: | - import netsvc - purch_ids = self.search(cr, uid, [('state','=','draft')]) - assert purch_ids, 'No Purchase Orders were made!' - wf_service = netsvc.LocalService("workflow") - for p_id in purch_ids: - wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr) -- - I see two incoming pickings for Orange and Sugar, and receive them. -- - !python {model: stock.picking}: | - pick_ids = self.search(cr, uid, [('type','=','in')]) - assert pick_ids, 'No Incoming Shipments found!' - stock_partial_picking = self.pool.get('stock.partial.picking') - for pick_id in pick_ids: - partial_id = stock_partial_picking.create(cr, uid, {}, - context={'active_model': 'stock.picking', - 'active_ids': [pick_id]}) - stock_partial_picking.do_partial(cr, uid, [partial_id]) -- - Again the scheduler runs. -- - !function {model: procurement.order, name: run_scheduler}: - - model: procurement.order - search: "[]" -- - I check my internal picking of "Orange Juice" is done. -- - !python {model: stock.picking}: | - pick_ids = self.search(cr, uid, [('type','=','internal'),('state','=','done')]) - assert pick_ids, 'Internal Picking is not done yet!' -- - I check my manufacturing order for "Orange Juice" is ready or not. -- - !python {model: mrp.production}: | - prod_ids = self.search(cr, uid, [('state','=','ready'),('id','=',ref('mrp_production_mo0'))]) - assert prod_ids, 'Manufacturing order is not ready!' -- - I start the production order. -- - !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo0} diff --git a/addons/mrp/test/mrp_procurement.yml b/addons/mrp/test/mrp_procurement.yml deleted file mode 100644 index 4aaf1560432..00000000000 --- a/addons/mrp/test/mrp_procurement.yml +++ /dev/null @@ -1,278 +0,0 @@ -- - In order to test the flow of procurement orders. I will put some orders with - different procurement methods. I have installed sale, mrp and purchase modules. -- - I am creating products. -- - I create record for product Shirt. -- - !record {model: product.product, id: product_product_shirt0}: - categ_id: product.cat1 - cost_method: standard - list_price: 350.0 - mes_type: fixed - name: Shirt - procure_method: make_to_stock - property_stock_inventory: stock.location_inventory - property_stock_procurement: stock.location_procurement - property_stock_production: stock.location_production - seller_delay: '1' - standard_price: 300.0 - supply_method: produce - 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 record for product Cloth. -- - !record {model: product.product, id: product_product_cloth0}: - categ_id: product.cat1 - cost_method: standard - mes_type: fixed - name: Cloth - procure_method: make_to_order - property_stock_inventory: stock.location_inventory - property_stock_procurement: stock.location_procurement - property_stock_production: stock.location_production - seller_delay: '1' - seller_ids: - - delay: 1 - name: base.res_partner_maxtor - product_uom: product.product_uom_unit - min_qty: 300.0 - standard_price: 1.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 record for product Buttons. -- - !record {model: product.product, id: product_product_buttons0}: - categ_id: product.cat1 - cost_method: standard - mes_type: fixed - name: Buttons - procure_method: make_to_stock - property_stock_inventory: stock.location_inventory - property_stock_procurement: stock.location_procurement - property_stock_production: stock.location_production - seller_delay: '1' - seller_ids: - - delay: 1 - name: base.res_partner_asus - product_uom: product.product_uom_kgm - min_qty: 100.0 - standard_price: 1.0 - supply_method: buy - type: product - uom_id: product.product_uom_kgm - uom_po_id: product.product_uom_kgm - volume: 0.0 - warranty: 0.0 - weight: 0.0 - weight_net: 0.0 -- - I am creating bills of material for 'Shirt'. -- - I create bills of material for Shirt. -- - !record {model: mrp.bom, id: mrp_bom_shirt0}: - bom_lines: - - company_id: base.main_company - name: Cloth - product_efficiency: 1.0 - product_id: product_product_cloth0 - product_qty: 1.0 - product_uom: product.product_uom_unit - product_uos_qty: 0.0 - sequence: 0.0 - type: normal - - company_id: base.main_company - name: Buttons - product_efficiency: 1.0 - product_id: product_product_buttons0 - product_qty: 8.0 - product_uom: product.product_uom_kgm - product_uos_qty: 0.0 - sequence: 0.0 - type: normal - company_id: base.main_company - name: Shirt - product_efficiency: 1.0 - product_id: product_product_shirt0 - product_qty: 1.0 - product_uom: product.product_uom_unit - product_uos_qty: 0.0 - sequence: 0.0 - type: normal -- - I create minimum stock rule for product Buttons -- - !record {model: stock.warehouse.orderpoint, id: stock_warehouse_orderpoint_op0}: - company_id: base.main_company - location_id: stock.stock_location_stock - logic: max - name: OP/00007 - product_id: mrp.product_product_buttons0 - product_max_qty: 50.0 - product_min_qty: 10.0 - product_uom: product.product_uom_kgm - qty_multiple: 1 - warehouse_id: stock.warehouse0 -- - I create a procurement order for product Shirt. -- - !record {model: procurement.order, id: procurement_order_shirt0}: - name: 'PROC: Shirt' - product_id: product_product_shirt0 - product_qty: 5.00 - location_id: stock.stock_location_stock - product_uom: product.product_uom_unit -- - I confirm the procurement order. -- - !workflow {model: procurement.order, action: button_confirm, ref: procurement_order_shirt0} -- - I run the procurement. -- - !workflow {model: procurement.order, action: button_check, ref: procurement_order_shirt0} -- - I see that there is a manufacturing order for Shirt. -- - !python {model: mrp.production}: | - from tools.translate import _ - order_ids = self.search(cr, uid, [('product_id','=',ref('product_product_shirt0'))]) - assert order_ids, 'No Manufacturing Order.' -- - I also check that there are two more procurement orders for sub products Cloth and Buttons. -- - !python {model: procurement.order}: | - from tools.translate import _ - proc_ids = self.search(cr, uid, [('product_id','in',[ref('product_product_cloth0'),ref('product_product_buttons0')])]) - assert proc_ids, 'No Procurements.' -- - The scheduler runs. -- - !function {model: procurement.order, name: run_scheduler}: - - model: procurement.order - search: "[]" -- - I check that there is one purchase order for Cloth. -- - !python {model: purchase.order}: | - purch_ids = self.search(cr, uid, [('partner_id.name','=','Maxtor')]) - assert purch_ids, 'No Purchase Orders.' -- - I confirm purchase order for Cloth. -- - !python {model: purchase.order}: | - import netsvc - purch_ids = self.search(cr, uid, [('partner_id.name','=','Maxtor')]) - wf_service = netsvc.LocalService("workflow") - for p_id in purch_ids: - wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr) - -- - I confirm purchase order for Buttons. -- - !python {model: purchase.order}: | - import netsvc - purch_ids = self.search(cr, uid, [('partner_id.name','=','ASUStek')]) - wf_service = netsvc.LocalService("workflow") - for p_id in purch_ids: - wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr) - -- - I Check incoming shipments for cloth. And receive products. -- - !python {model: stock.picking}: | - pick_ids = self.search(cr, uid, [('address_id.name','=','Wong'),('state','=','assigned')]) - assert pick_ids, 'No Incoming Shipments found!' - stock_partial_picking = self.pool.get('stock.partial.picking') - for pick_id in pick_ids: - partial_id = stock_partial_picking.create(cr, uid, {}, - context={'active_model': 'stock.picking', - 'active_ids': [pick_id]}) - stock_partial_picking.do_partial(cr, uid, [partial_id]) -- - I Check incoming shipments for buttons and receive products. -- - !python {model: stock.picking}: | - pick_ids = self.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')]) - assert pick_ids, 'No Incoming Shipments found!' - stock_partial_picking = self.pool.get('stock.partial.picking') - for pick_id in pick_ids: - partial_id = stock_partial_picking.create(cr, uid, {}, - context={'active_model': 'stock.picking', - 'active_ids': [pick_id]}) - stock_partial_picking.do_partial(cr, uid, [partial_id]) -- - Run scheduler again. -- - !function {model: procurement.order, name: run_scheduler}: - - model: procurement.order - search: "[]" -- - Check state of manufacturing order for Shirt. -- - !python {model: mrp.production}: | - from tools.translate import _ - order_ids = self.search(cr, uid, [('product_id','=',ref('product_product_shirt0')),('state','=','ready')]) - assert order_ids, 'No Manufacturing Order in Ready state.' -- - I start production order for Shirt. -- - !python {model: mrp.production}: | - from tools.translate import _ - import netsvc - prod_ids = self.search(cr, uid, [('state','=','ready')]) - assert prod_ids, _('No Ready Manufacturing Orders found!') - wf_service = netsvc.LocalService("workflow") - for p_id in prod_ids: - wf_service.trg_validate(uid, 'mrp.production', p_id, 'button_produce', cr) -- - I create record for producing products with quantity 5.00. -- - !record {model: mrp.product.produce, id: mrp_product_produce0}: - product_qty: 5.00 - mode: 'consume_produce' -- - I produce 2 products with 5.00 quantities each. -- - !python {model: mrp.product.produce}: | - prod_obj = self.pool.get('mrp.production') - prod_ids = prod_obj.search(cr, uid, [('product_id.name','=','Shirt')]) - self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids}) -- - I create record for remaining products with quantity 35.00. -- - !record {model: stock.move.consume, id: stock_move_consume0}: - product_id: product_product_buttons0 - product_qty: 35.00 - product_uom: product.product_uom_unit - location_id: stock.stock_location_stock -- - I produce remaining product Buttons with 35.00 quantity. -- - !python {model: stock.move.consume}: | - from tools.translate import _ - stock_obj = self.pool.get('stock.move') - stock_ids = stock_obj.search(cr, uid, [('product_id.name','=','Buttons')]) - self.do_move_consume(cr, uid, [ref('stock_move_consume0')], context={'active_ids': stock_ids}) -- - And finally production order is done. -- - !python {model: mrp.product.produce}: | - prod_obj = self.pool.get('mrp.production') - prod_ids = prod_obj.search(cr, uid, [('product_id.name','=','Shirt')]) - self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids}) - From d05789a53c430d510191a800e2295cf656a63871 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Fri, 14 Oct 2011 16:24:23 +0530 Subject: [PATCH 07/44] [ADD]: mrp: Added new production order in demo data bzr revid: rpa@tinyerp.com-20111014105423-jk9plj6cghgkmdj3 --- addons/mrp/mrp_demo.xml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index d19a99a12ca..9795a26f6cd 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -716,9 +716,18 @@ - + + + + + + + + + + From cc6382e442f84e0e979b0a966364514cffd30fbb Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Fri, 14 Oct 2011 16:57:55 +0530 Subject: [PATCH 08/44] [REM, REF]: mrp: Commented dead code in product.py bzr revid: rpa@tinyerp.com-20111014112755-mzsh5hdr7msv0zc5 --- addons/mrp/product.py | 46 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/addons/mrp/product.py b/addons/mrp/product.py index 9731d93f84b..6ade4f670dd 100644 --- a/addons/mrp/product.py +++ b/addons/mrp/product.py @@ -26,28 +26,30 @@ from tools.translate import _ class product_product(osv.osv): _inherit = "product.product" - def get_product_accounts(self, cr, uid, product_id, context=None): - """ To get the stock input account, stock output account and stock journal related to product. - @param product_id: product id - @return: dictionary which contains information regarding stock input account, stock output account and stock journal - """ - product_obj = self.pool.get('product.product').browse(cr, uid, product_id, False) - res = super(product_product,self).get_product_accounts(cr, uid, product_id, context=context) - stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False - if not stock_input_acc: - stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False - - stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False - if not stock_output_acc: - stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False - - journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False - - res.update({'stock_account_input': stock_input_acc}) - res.update({'stock_account_output': stock_output_acc}) - res.update({'stock_journal': journal_id}) - - return res + # TODO: DEAD CODE: This function was called from do_change_standard_price, + # but as that function is removed for the fix of lp:747056, its not reached +# def get_product_accounts(self, cr, uid, product_id, context=None): +# """ To get the stock input account, stock output account and stock journal related to product. +# @param product_id: product id +# @return: dictionary which contains information regarding stock input account, stock output account and stock journal +# """ +# product_obj = self.pool.get('product.product').browse(cr, uid, product_id, False) +# res = super(product_product,self).get_product_accounts(cr, uid, product_id, context=context) +# stock_input_acc = product_obj.property_stock_account_input and product_obj.property_stock_account_input.id or False +# if not stock_input_acc: +# stock_input_acc = product_obj.categ_id.property_stock_account_input_categ and product_obj.categ_id.property_stock_account_input_categ.id or False +# +# stock_output_acc = product_obj.property_stock_account_output and product_obj.property_stock_account_output.id or False +# if not stock_output_acc: +# stock_output_acc = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id or False +# +# journal_id = product_obj.categ_id.property_stock_journal and product_obj.categ_id.property_stock_journal.id or False +# +# res.update({'stock_account_input': stock_input_acc}) +# res.update({'stock_account_output': stock_output_acc}) +# res.update({'stock_journal': journal_id}) +# +# return res _columns = { From 9537b9420dcc8d1aa0182cc2a1ab3e1f1bdf8e96 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Mon, 17 Oct 2011 17:30:35 +0530 Subject: [PATCH 09/44] [IMP]: mrp: minor improvement in test statement of yml bzr revid: rpa@tinyerp.com-20111017120035-a6m3oqnszdeux0tf --- addons/mrp/test/mrp_production_order.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/test/mrp_production_order.yml b/addons/mrp/test/mrp_production_order.yml index d24cbf5bc69..a151e0b93d2 100644 --- a/addons/mrp/test/mrp_production_order.yml +++ b/addons/mrp/test/mrp_production_order.yml @@ -30,7 +30,7 @@ pick_ids = self.browse(cr, uid, ref("mrp_production_mo1")) assert pick_ids.picking_id.id, _('No Internal Picking created for this manufacturing order!') - - I remembered that we have to produce 6 PC1 instead of 5.0, so I create record for wizard 'Change Qty' changing production quantity to 6.0 + I remembered that we have to produce 6.0 PC1 instead of 5.0, so I create record for wizard 'Change Qty' changing production quantity to 6.0 - !record {model: change.production.qty, id: mrp_production_qty}: product_qty: 6.0 From d5ac2944fd7b5076aa67cd087bc29e39d078579a Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Mon, 17 Oct 2011 18:12:36 +0530 Subject: [PATCH 10/44] [IMP, REM]: mrp: Improvement in test cases of cancel production order: * Removed creation of data in yml and taken reference of existing demo for ease bzr revid: rpa@tinyerp.com-20111017124236-wtapn1nmblxb02dw --- addons/mrp/test/mrp_production_cancel.yml | 37 ++++++++++------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/addons/mrp/test/mrp_production_cancel.yml b/addons/mrp/test/mrp_production_cancel.yml index 1dc20a215d1..860d3de2835 100644 --- a/addons/mrp/test/mrp_production_cancel.yml +++ b/addons/mrp/test/mrp_production_cancel.yml @@ -1,29 +1,24 @@ - - In order to test the manufacturing order in Openerp, - I am creating one manufacturing order + In order to test effect of cancelling Internal picking on production order, I first confirm order for PC3. - - !record {model: mrp.production, id: mrp_production_mo1}: - 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_pc1 - name: MO/01234 - product_qty: 5.0 - product_uom: product.product_uom_unit - product_uos_qty: 0.0 + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order2} - - I confirm the order. + I check that the related internal picking is waiting availability. - - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1} + !assert {model: mrp.production, id: mrp_production_order2}: + - picking_id.state == 'confirmed' - - In order to cancel the MO, I first cancel its picking. + In order to cancel the production order, I first cancel its picking. - - !python {model: stock.picking}: | - mrp_obj = self.pool.get('mrp.production') - mo = mrp_obj.browse(cr, uid, ref("mrp_production_mo1")) - self.action_cancel(cr, uid, [mo.picking_id.id], context=None) + !function {model: stock.picking, name: action_cancel}: + - model: mrp.production + eval: "[obj(ref('mrp_production_order2')).picking_id.id]" - - Then I Cancel the production order and related stock moves. + Now I cancel the production order. - - !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_mo1} \ No newline at end of file + !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_order2} +- + Now I check that the production order is cancelled. +- + !assert {model: mrp.production, id: mrp_production_order2}: + - state == 'cancel' From 83839920a202393dd68cbffcc0fd5637ea293697 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Tue, 18 Oct 2011 16:32:48 +0530 Subject: [PATCH 11/44] [IMP]: mrp: Added test to unlink production order bzr revid: rpa@tinyerp.com-20111018110248-zq2kcsd08r7uvl9s --- addons/mrp/test/mrp_production_cancel.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/mrp/test/mrp_production_cancel.yml b/addons/mrp/test/mrp_production_cancel.yml index 860d3de2835..7063fa94227 100644 --- a/addons/mrp/test/mrp_production_cancel.yml +++ b/addons/mrp/test/mrp_production_cancel.yml @@ -22,3 +22,7 @@ - !assert {model: mrp.production, id: mrp_production_order2}: - state == 'cancel' +- + I remove this production order. +- + !delete {model: mrp.production, id: mrp_production_order2} From fba0c10d362a3931d75de22f20c8ba620f5dc5b6 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Tue, 18 Oct 2011 16:46:57 +0530 Subject: [PATCH 12/44] [FIX]: mrp: Fixed wrong reference in demo of BOM for "RAM on demand" bzr revid: rpa@tinyerp.com-20111018111657-ecgqrj6xd5lm5g5d --- addons/mrp/mrp_demo.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index 9795a26f6cd..e6986fcb6a1 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -214,7 +214,7 @@ - RAM on demand + RAM512 on demand 18 1.0 @@ -254,12 +254,12 @@ - RAM on demand + RAM256 on demand 36 1.0 phantom - + From 6069ecabe00659d1294812027227489f219d7310 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Tue, 18 Oct 2011 16:52:05 +0530 Subject: [PATCH 13/44] [FIX]: mrp: for the BOM of [PC0] Complete PC With Peripherals there was 2 boms PC1 and KIT0, but as PC1 was having KIT0 as its component it did not suit there. PC2 is right option as its having components other than KIT0 bzr revid: rpa@tinyerp.com-20111018112205-vfmy2rmvs6z7nn37 --- addons/mrp/mrp_demo.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index e6986fcb6a1..571b1d22c05 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -302,7 +302,7 @@ 1.0 - + Mainboard ASUStek A7N8X From 21e069e171b67182d03452034f4f19f104d7542b Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Wed, 19 Oct 2011 10:54:40 +0530 Subject: [PATCH 14/44] [IMP]: mrp: Improvement in demo of KIT0 (keyboard and mouse): * Before there were 2 normal BOM components for KIT0 used in PC0 and PC1 having BOM lines of mouse and keyboard as subcomponents * Now changed that 2 normal BOMs to phantom BOMs without subcomponents and created one common normal BOM of KIT0 in order to use concept of phantom BOMs easily bzr revid: rpa@tinyerp.com-20111019052440-ev9csw84d51lpf2j --- addons/mrp/mrp_demo.xml | 72 ++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index 571b1d22c05..3d2d30e3e15 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -270,32 +270,17 @@ - + KIT - Kit Mouse + Kit Keyboard + Mouse 40 1.0 - normal + phantom - - - - Keyboard - 42 - - 1.0 - - - - - Mouse - 44 - - 1.0 - - + + Moon PC 45 @@ -502,6 +487,35 @@ + + + KIT + 15 + Kit Keyboard + Mouse + + 1.0 + normal + + + + + Mouse + 121 + + 1.0 + + + + + + Keyboard + 123 + + 1.0 + + + + Regular processor config 111 @@ -536,26 +550,10 @@ Kit Keyboard + Mouse 1.0 - normal + phantom - - Mouse - 121 - - 1.0 - - - - - Keyboard - 123 - - 1.0 - - - - [1] Assembly Line 1 - [2] Custom Assembly Line - [3] Component Manufacturing @@ -168,6 +165,12 @@ 3 assembly main + processor + fan + + + + Packing + 0.5 + - - - - - - - - - - - diff --git a/addons/mrp/mrp_production_order_demo.yml b/addons/mrp/mrp_production_order_demo.yml new file mode 100644 index 00000000000..d9f117092dd --- /dev/null +++ b/addons/mrp/mrp_production_order_demo.yml @@ -0,0 +1,25 @@ +- + !record {model: mrp.production, id: mrp_production_order1}: + location_src_id: stock.stock_location_stock + location_dest_id: stock.stock_location_output + product_id: product.product_product_pc1 + name: MO/00001 + product_qty: 5.0 + product_uos_qty: 5.0 +- + !function {model: mrp.production, name: action_compute, id: mrp_production_order1}: + - model: mrp.production + eval: "[obj(ref('mrp_production_order1')).id]" + +- + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order1} +- + !record {model: mrp.production, id: mrp_production_order2}: + location_src_id: stock.stock_location_stock + product_id: product.product_product_kitshelfofcm0 + product_qty: 5.0 + product_uos_qty: 5.0 +- + !record {model: mrp.production, id: mrp_production_order3}: + location_src_id: stock.stock_location_stock + product_id: product.product_product_pc3 diff --git a/addons/mrp/test/mrp_packs.yml b/addons/mrp/test/mrp_packs.yml index b5c4065652e..9816ac856f9 100644 --- a/addons/mrp/test/mrp_packs.yml +++ b/addons/mrp/test/mrp_packs.yml @@ -1,7 +1,7 @@ - In order to test the Packs in OpenERP, we will try to sell a "KIT Shelf of 100cm" which is composed of "[PROFIL] Assembly Section" and "[SIDEPAN] Side Panel" having Phantom BOM. - - As all my data are already available, I will create an outgoing order picking for 2 "KIT Shelf of 100cm" + I will create an outgoing order picking for 2 "KIT Shelf of 100cm" - !record {model: stock.picking, id: picking_out}: address_id: base.res_partner_address_tang diff --git a/addons/mrp/test/mrp_production_cancel.yml b/addons/mrp/test/mrp_production_cancel.yml index 7063fa94227..76f3a9cec3c 100644 --- a/addons/mrp/test/mrp_production_cancel.yml +++ b/addons/mrp/test/mrp_production_cancel.yml @@ -1,28 +1,28 @@ - In order to test effect of cancelling Internal picking on production order, I first confirm order for PC3. - - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order2} + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order3} - I check that the related internal picking is waiting availability. - - !assert {model: mrp.production, id: mrp_production_order2}: + !assert {model: mrp.production, id: mrp_production_order3}: - picking_id.state == 'confirmed' - In order to cancel the production order, I first cancel its picking. - !function {model: stock.picking, name: action_cancel}: - model: mrp.production - eval: "[obj(ref('mrp_production_order2')).picking_id.id]" + eval: "[obj(ref('mrp_production_order3')).picking_id.id]" - Now I cancel the production order. - - !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_order2} + !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_order3} - Now I check that the production order is cancelled. - - !assert {model: mrp.production, id: mrp_production_order2}: + !assert {model: mrp.production, id: mrp_production_order3}: - state == 'cancel' - I remove this production order. - - !delete {model: mrp.production, id: mrp_production_order2} + !delete {model: mrp.production, id: mrp_production_order3} diff --git a/addons/mrp/test/mrp_production_order.yml b/addons/mrp/test/mrp_production_order.yml index 237da35ab06..ffa9280d249 100644 --- a/addons/mrp/test/mrp_production_order.yml +++ b/addons/mrp/test/mrp_production_order.yml @@ -1,27 +1,9 @@ - - In order to test the manufacturing order working with procurements I will create manufacturing orders of products having different configuration and check the flow. + In order to test the manufacturing order working with procurements I will check different manufacturing orders of different products having different configuration and check the flow. - - I am creating a manufacturing order of 5 PC1-Basic PC which has 'Assembly Basic PC' as its BOM. + I create record for wizard 'Change Qty' as we have to produce 6.0 PC1 instead of 5.0, - - !record {model: mrp.production, id: mrp_production_mo1}: - 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_pc1 - name: MO/0123 - product_qty: 5.0 - product_uom: product.product_uom_unit - product_uos_qty: 5.0 -- - I click on the "Compute Data" to compute work centre and scheduled product. -- - !python {model: mrp.production}: | - self.action_compute(cr, uid, [ref("mrp_production_mo1")]) -- - I remembered that we have to produce 6.0 PC1 instead of 5.0, so I create record for wizard 'Change Qty'. -- - !record {model: change.production.qty, id: mrp_production_qty, context: "{'active_id': ref('mrp_production_mo1')}"}: + !record {model: change.production.qty, id: mrp_production_qty, context: "{'active_id': ref('mrp_production_order1')}"}: - I change value to 6.0 - @@ -31,44 +13,44 @@ I Approve change qty wizard for 6.0 PC1. - !python {model: change.production.qty}: | - context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')} + context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_order1")], "tz": False, "active_id":ref('mrp_production_order1')} self.change_prod_qty(cr, uid, [ref("mrp_production_qty")], context=context) - I confirm the manufacturing order for 5 PC1. - - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1} -- - I check there is an internal picking for this MO to bring components in Raw Materials Location. -- - !python {model: mrp.production}: | - from tools.translate import _ - pick_ids = self.browse(cr, uid, ref("mrp_production_mo1")) - assert pick_ids.picking_id.id, _('No Internal Picking created for this manufacturing order!') -- + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order1} +- I compute the scheduler to procure the components based on their supply method. - !function {model: procurement.order, name: run_scheduler}: - model: procurement.order search: "[]" +- + I check there is an internal picking for this MO to bring components in Raw Materials Location. +- + !python {model: mrp.production}: | + from tools.translate import _ + pick_ids = self.browse(cr, uid, ref("mrp_production_order1")) + assert pick_ids.picking_id.id, _('No Internal Picking created for this manufacturing order!') - I see that there is a manufacturing order for the sub product CPU_GEN with ready state and I start production of it. - !python {model: mrp.production}: | from tools.translate import _ - order_ids = self.search(cr, uid, [('state','=','ready'), ('product_id', '=', ref('product.product_product_cpu_gen')), ('origin', 'ilike', '%MO/0123%')]) + order_ids = self.search(cr, uid, [('state','=','ready'), ('product_id', '=', ref('product.product_product_cpu_gen')), ('origin', 'ilike', '%MO/00001%')]) assert order_ids, _('No manufacturing order in Ready state for CPU_GEN!') import netsvc wf_service = netsvc.LocalService("workflow") for order in order_ids: wf_service.trg_validate(uid, 'mrp.production', order, 'button_produce', cr) - - Now to produce CPU_GEN, I create record of wizard 'Consume & Produce' with quantity 6.0. + Now to produce CPU_GEN, I create record of wizard 'Consume & Produce'. - !record {model: mrp.product.produce, id: mrp_product_produce0}: - product_qty: 6.0 mode: 'consume_produce' + product_qty: 5.0 - - I confirm the production of 6.0 CPU_GEN. + I confirm the production of CPU_GEN. - !python {model: mrp.product.produce}: | prod_obj = self.pool.get('mrp.production') @@ -77,25 +59,25 @@ - Component CPU_GEN is produced and now manufacturing order for PC1 is ready to produce. - - !assert {model: mrp.production, id: mrp_production_mo1}: + !assert {model: mrp.production, id: mrp_production_order1}: - state == 'ready' - I start production of PC1. - - !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo1} + !workflow {model: mrp.production, action: button_produce, ref: mrp_production_order1} - I create record for producing products with quantity 6.0. - - !record {model: mrp.product.produce, id: mrp_product_produce1, context: "{'active_id': ref('mrp_production_mo1')}"}: + !record {model: mrp.product.produce, id: mrp_product_produce1, context: "{'active_id': ref('mrp_production_order1')}"}: mode: 'consume_produce' - I produce the products by clicking on 'Produce' - !python {model: mrp.product.produce}: | - context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_mo1")], "tz": False, "active_id":ref('mrp_production_mo1')} + context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_order1")], "tz": False, "active_id":ref('mrp_production_order1')} self.do_produce(cr, uid, [ref('mrp_product_produce1')], context=context) - I check now the production order for 6.0 PC1 is done. - - !assert {model: mrp.production, id: mrp_production_mo1}: + !assert {model: mrp.production, id: mrp_production_order1}: - state == 'done' diff --git a/addons/mrp/test/mrp_report.yml b/addons/mrp/test/mrp_report.yml index 48126b5edcd..c9712e67398 100644 --- a/addons/mrp/test/mrp_report.yml +++ b/addons/mrp/test/mrp_report.yml @@ -12,7 +12,7 @@ - !python {model: mrp.production}: | import netsvc, tools, os - (data, format) = netsvc.LocalService('report.mrp.production.order').create(cr, uid, [ref('mrp.mrp_production_mo1')], {}, {}) + (data, format) = netsvc.LocalService('report.mrp.production.order').create(cr, uid, [ref('mrp.mrp_production_order1')], {}, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'mrp-production_order_report.'+format), 'wb+').write(data) diff --git a/addons/mrp/test/production_order_consume.yml b/addons/mrp/test/production_order_consume.yml index 605929640e7..9cd010a63a2 100644 --- a/addons/mrp/test/production_order_consume.yml +++ b/addons/mrp/test/production_order_consume.yml @@ -1,33 +1,21 @@ - - I create production order of 5.0 KIT Shelf of 100cm to test partial consumption and production. + I confirm the production order of 5.0 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 production order. -- - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo3} + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order2} - 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")]) + self.force_production(cr, uid, [ref("mrp_production_order2")]) - I mark KIT Shelf as in production. - - !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo3} + !workflow {model: mrp.production, action: button_produce, ref: mrp_production_order2} - I Consume 4.0 Side Panels first and scrap one damaged Side Panel. - !python {model: mrp.production}: | - production = self.browse(cr, uid, ref("mrp_production_mo3")) + production = self.browse(cr, uid, ref("mrp_production_order2")) 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] @@ -39,14 +27,14 @@ 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')} + context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_order2")], "tz": False, "active_id":ref('mrp_production_order2')} 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")) + production = self.browse(cr, uid, ref("mrp_production_order2")) 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 @@ -54,24 +42,24 @@ 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')} + context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_order2")], "tz": False, "active_id":ref('mrp_production_order2')} wiz_id = self.create(cr, uid, {'mode': 'consume'}, context=context) self.do_produce(cr, uid, [wiz_id], context=context) - I check now there is nothing remaining in Products to Consume. - !python {model: mrp.production}: | - production = self.browse(cr, uid, ref("mrp_production_mo3")) + production = self.browse(cr, uid, ref("mrp_production_order2")) 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')} + context = {"lang": 'en_US', "active_model":"mrp.production", "active_ids": [ref("mrp_production_order2")], "tz": False, "active_id":ref('mrp_production_order2')} 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}: + !assert {model: mrp.production, id: mrp_production_order2}: - state == 'done' From 235c952f8b2a061fc77b5d020166d051c97f947d Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Thu, 17 Nov 2011 18:58:11 +0530 Subject: [PATCH 36/44] [ADD,IMP]: mrp_operations: created new demo yml for production orders so that we can use those demo in yaml test files, * Improved reference of demo data in yml + removed creation of demo bzr revid: rpa@tinyerp.com-20111117132811-uf05we1fyg3h3inz --- addons/mrp/mrp_production_order_demo.yml | 1 - addons/mrp_operations/__openerp__.py | 3 ++- addons/mrp_operations/mrp_operations_demo.yml | 24 ++++++++++++++++++ .../test/check_mo2operations.yml | 14 +---------- .../mrp_operations/test/check_mo_cancel.yml | 14 +---------- .../test/check_operations2mo.yml | 25 +------------------ 6 files changed, 29 insertions(+), 52 deletions(-) create mode 100644 addons/mrp_operations/mrp_operations_demo.yml diff --git a/addons/mrp/mrp_production_order_demo.yml b/addons/mrp/mrp_production_order_demo.yml index d9f117092dd..d014f281a04 100644 --- a/addons/mrp/mrp_production_order_demo.yml +++ b/addons/mrp/mrp_production_order_demo.yml @@ -10,7 +10,6 @@ !function {model: mrp.production, name: action_compute, id: mrp_production_order1}: - model: mrp.production eval: "[obj(ref('mrp_production_order1')).id]" - - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order1} - diff --git a/addons/mrp_operations/__openerp__.py b/addons/mrp_operations/__openerp__.py index 7631ea8e5f8..e7543302db9 100644 --- a/addons/mrp_operations/__openerp__.py +++ b/addons/mrp_operations/__openerp__.py @@ -64,7 +64,8 @@ So that we can compare the theoretic delay and real delay. 'report/mrp_workorder_analysis_view.xml', 'process/mrp_operation_process.xml' ], - 'demo_xml': ['mrp_operation_data.xml'], + 'demo_xml': ['mrp_operation_data.xml', + 'mrp_operations_demo.yml'], 'test': ['test/check_mo2operations.yml', 'test/check_operations2mo.yml', 'test/check_mo_cancel.yml', diff --git a/addons/mrp_operations/mrp_operations_demo.yml b/addons/mrp_operations/mrp_operations_demo.yml new file mode 100644 index 00000000000..7bfef8a4c7b --- /dev/null +++ b/addons/mrp_operations/mrp_operations_demo.yml @@ -0,0 +1,24 @@ +- + !record {model: mrp.production, id: mrp_production_op}: + location_src_id: stock.stock_location_stock + product_id: product.product_product_cpu3 + product_qty: 5.0 + allow_reorder: True +- + !record {model: mrp.production, id: mrp_production_op1}: + location_src_id: stock.stock_location_stock + product_id: product.product_product_cpu3 + product_qty: 2.0 +- + !function {model: mrp.production, name: action_compute, id: mrp_production_op1}: + - model: mrp.production + eval: "[obj(ref('mrp_production_op1')).id]" +- + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_op1} +- + !record {model: mrp.production, id: mrp_production_mo1}: + location_src_id: stock.stock_location_stock + product_id: product.product_product_cpu_gen + product_qty: 5.0 +- + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1} diff --git a/addons/mrp_operations/test/check_mo2operations.yml b/addons/mrp_operations/test/check_mo2operations.yml index 365c8e26e91..c5165ded1c3 100644 --- a/addons/mrp_operations/test/check_mo2operations.yml +++ b/addons/mrp_operations/test/check_mo2operations.yml @@ -1,17 +1,5 @@ - - In order to test effect of relation between production orders and work orders, I create a production order. -- - First I will see how changing production order will effect work orders, -- - !record {model: mrp.production, id: mrp_production_op}: - 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_cpu3 - product_qty: 5.0 - product_uos_qty: 5.0 - allow_reorder: True + In order to test effect of relation between production orders and work orders, first I will see how changing production order will effect work orders, - I am computing the data. - diff --git a/addons/mrp_operations/test/check_mo_cancel.yml b/addons/mrp_operations/test/check_mo_cancel.yml index c285877f2c3..2a8f58b2a37 100644 --- a/addons/mrp_operations/test/check_mo_cancel.yml +++ b/addons/mrp_operations/test/check_mo_cancel.yml @@ -1,17 +1,5 @@ - - Now I will check how cancelling production order will affect its work orders. -- - !record {model: mrp.production, id: mrp_production_mo1}: - location_src_id: stock.stock_location_stock - product_id: product.product_product_cpu_gen - product_qty: 5.0 - product_uos_qty: 5.0 -- - Now I confirm the production order. -- - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo1} -- - I check that there is one Work order generated related to the production order. + I check that there is one Work order generated related to the production order of 5 CPU_GEN. - !python {model: mrp.production.workcenter.line}: | from tools.translate import _ diff --git a/addons/mrp_operations/test/check_operations2mo.yml b/addons/mrp_operations/test/check_operations2mo.yml index 8797c00b9ff..aacd7e5ae3c 100644 --- a/addons/mrp_operations/test/check_operations2mo.yml +++ b/addons/mrp_operations/test/check_operations2mo.yml @@ -1,28 +1,5 @@ - - Now I will see how changing work orders will effect production order, -- - !record {model: mrp.production, id: mrp_production_op1}: - 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_cpu3 - product_qty: 2.0 - product_uos_qty: 2.0 -- - I am computing the data. -- - !python {model: mrp.production}: | - self.action_compute(cr, uid, [ref("mrp_production_op1")], {"lang": "en_US", "tz": - False, "search_default_current": 1, "active_model": "ir.ui.menu", "active_ids": - [ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"), - }) -- - Now I confirm the production order. -- - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_op1} -- - I check that there are two work orders generated for this production order. + I check that there are two work orders generated for the production order of 2 CPU3. - !assert {model: mrp.production, id: mrp_production_op1, string: Operation is started.}: - len(workcenter_lines) == 2 From b7035ee536b41cb34fd1cc6f1967dd12c5af8143 Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Thu, 17 Nov 2011 19:01:10 +0530 Subject: [PATCH 37/44] [REM]: mrp: removed commented file bzr revid: rpa@tinyerp.com-20111117133110-88fvw6x1sm3fl8r2 --- addons/mrp/__openerp__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/mrp/__openerp__.py b/addons/mrp/__openerp__.py index d635eedea33..223d574f7c3 100644 --- a/addons/mrp/__openerp__.py +++ b/addons/mrp/__openerp__.py @@ -98,8 +98,6 @@ Dashboard provided by this module: 'test/mrp_packs.yml', 'test/mrp_production_cancel.yml', 'test/mrp_report.yml', -# 'test/mrp_procurement.yml', -# 'test/mrp_phantom_bom.yml', ], 'installable': True, 'active': False, From 84a068555722bfda5db914fe7726d426c4b860f0 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Fri, 9 Dec 2011 16:51:31 +0530 Subject: [PATCH 38/44] [IMP] mrp: clean test case and demo data of BoM, resolve test failure bzr revid: hmo@tinyerp.com-20111209112131-qhzdza73ucze8apr --- addons/mrp/__openerp__.py | 1 - addons/mrp/mrp.py | 7 +- addons/mrp/mrp_demo.xml | 228 +++++++++++++++++------ addons/mrp/test/cancel_order.yml | 21 +-- addons/mrp/test/order_demo.yml | 12 +- addons/mrp/test/order_process.yml | 115 +++++++----- addons/mrp/wizard/mrp_product_produce.py | 21 +-- addons/product/product_demo.xml | 27 ++- 8 files changed, 287 insertions(+), 145 deletions(-) diff --git a/addons/mrp/__openerp__.py b/addons/mrp/__openerp__.py index f114660aecf..8d1fb018987 100644 --- a/addons/mrp/__openerp__.py +++ b/addons/mrp/__openerp__.py @@ -90,7 +90,6 @@ Dashboard provided by this module: ], 'demo_xml': [ 'mrp_demo.xml', - 'mrp_production_order_demo.yml' ], 'test': [ 'test/order_demo.yml', diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 07c46c13017..d2760deedbd 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -312,6 +312,7 @@ class mrp_bom(osv.osv): phantom = False if bom.type == 'phantom' and not bom.bom_lines: newbom = self._bom_find(cr, uid, bom.product_id.id, bom.product_uom.id, properties) + if newbom: res = self._bom_explode(cr, uid, self.browse(cr, uid, [newbom])[0], factor*bom.product_qty, properties, addthis=True, level=level+10) result = result + res[0] @@ -579,7 +580,7 @@ class mrp_production(osv.osv): self.write(cr, uid, ids, {'state': 'picking_except'}) return True - def action_compute(self, cr, uid, ids, properties=[]): + def action_compute(self, cr, uid, ids, properties=[], context=None): """ Computes bills of material of a product. @param properties: List containing dictionaries of properties. @return: No. of products. @@ -957,7 +958,7 @@ class mrp_production(osv.osv): destination_location_id = production.product_id.product_tmpl_id.property_stock_production.id if not source_location_id: source_location_id = production.location_src_id.id - move_id = move_obj.create(cr, uid, { + move_id = stock_move.create(cr, uid, { 'name': move_name, 'date': production.date_planned, 'product_id': production_line.product_id.id, @@ -971,7 +972,7 @@ class mrp_production(osv.osv): 'state': 'waiting', 'company_id': production.company_id.id, }) - production.write('move_lines': [(4, move_id)]}, context=context) + production.write({'move_lines': [(4, move_id)]}, context=context) return move_id def action_confirm(self, cr, uid, ids, context=None): diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index 4386c492b1f..45958601f05 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -559,73 +559,160 @@ - + + Default BOM for Shelf of 100cm SHE100 - 129 + 10 1.0 - - Assembly Section - 123 - - - 4.0 - - - + + Side Panel - 125 + 101 2.0 - - Metal Cleats - 127 - + + Assembly Section + 102 + - 12.0 + 4.0 + phantom - 131 + 103 1.0 Rear panel SHE100 + phantom - 133 + 104 3.0 - Shelf 100 + RCK100 + phantom + + + + + 133 + + + 1.0 + RCK100 + + + 1331 + + + + 1.0 + phantom + SPAN100 + + + 1332 + + + + 4.0 + METC000 + + + + 135 + + + 1.0 + SPAN100 + + + 1351 + + + + 0.083 + WOOD010 + + + + Assembly Section + 123 + + + 1.0 + - 135 + 1231 - - 1.0 - - Wood Lintel 4m + 0.25 + + Wood Lintel 0.25m + + + 131 + + + 1.0 + Rear panel SHE100 + + + 1311 + + + + 0.25 + WOOD002 0.25m + + Default BOM for Shelf of 200cm @@ -636,34 +723,14 @@ 1.0 - - Default BOM for KIT Shelf of 100cm - SHE100KIT - 139 - - - 1.0 - phantom - - - - Assembly Section - 143 - - - 4.0 - - - - - Side Panel - 145 - - - 2.0 - - - + 147 @@ -709,18 +776,54 @@ + + Default BOM for KIT Shelf of 100cm + SHE100KIT + 139 + + + 1.0 + phantom + + + + + + Assembly Section + 143 + + + 4.0 + + + + + Side Panel + 145 + + + 2.0 + + + + + - t - + Dozen + bigger - - 5 + + 3 @@ -755,9 +858,10 @@ - + + 1.0 @@ -769,7 +873,7 @@ - + @@ -784,7 +888,7 @@ - + @@ -874,7 +978,7 @@ - + @@ -889,7 +993,7 @@ - + diff --git a/addons/mrp/test/cancel_order.yml b/addons/mrp/test/cancel_order.yml index 76f3a9cec3c..d10b8c1780b 100644 --- a/addons/mrp/test/cancel_order.yml +++ b/addons/mrp/test/cancel_order.yml @@ -1,28 +1,25 @@ - - In order to test effect of cancelling Internal picking on production order, I first confirm order for PC3. + I first confirm order for shirt. - - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_order3} -- - I check that the related internal picking is waiting availability. -- - !assert {model: mrp.production, id: mrp_production_order3}: - - picking_id.state == 'confirmed' + !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_shirt} - In order to cancel the production order, I first cancel its picking. - !function {model: stock.picking, name: action_cancel}: - model: mrp.production - eval: "[obj(ref('mrp_production_order3')).picking_id.id]" + eval: "[obj(ref('mrp_production_shirt')).picking_id.id]" - Now I cancel the production order. - - !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_order3} + !workflow {model: mrp.production, action: button_cancel, ref: mrp_production_shirt} - Now I check that the production order is cancelled. - - !assert {model: mrp.production, id: mrp_production_order3}: + !assert {model: mrp.production, id: mrp_production_shirt}: - state == 'cancel' - - I remove this production order. + I remove cancelled production order. - - !delete {model: mrp.production, id: mrp_production_order3} + !python {model: mrp.production}: | + order = self.browse(cr, uid, ref("mrp_production_shirt"), context=context) + self.unlink(cr, uid, [order.id]) diff --git a/addons/mrp/test/order_demo.yml b/addons/mrp/test/order_demo.yml index 4064262c78f..5015f604ce4 100644 --- a/addons/mrp/test/order_demo.yml +++ b/addons/mrp/test/order_demo.yml @@ -1,12 +1,16 @@ - - !record {model: mrp.bom, id: mrp_bom_metalcleats3}: - product_id: product.product_product_metalcleats0 - + In order to test process of production order, I create Bill of material of Shelf 100cm. - - !record {model: mrp.production, id: mrp_production_shelf}: + !record {model: mrp.bom, id: mrp_bom_defaultbomforshelfofcm0}: + product_id: product.product_product_shelfofcm0 +- + I create Production Order of Shelf 100cm to produce 5.0 Dozen PCE. +- + !record {model: mrp.production, id: mrp_production_shelf100cm}: location_src_id: stock.stock_location_stock location_dest_id: stock.stock_location_output product_id: product.product_product_shelfofcm0 bom_id: mrp_bom_defaultbomforshelfofcm0 + product_uom: product.product_uom_dozen product_qty: 5.0 diff --git a/addons/mrp/test/order_process.yml b/addons/mrp/test/order_process.yml index bced289a2d9..ce1b8864422 100644 --- a/addons/mrp/test/order_process.yml +++ b/addons/mrp/test/order_process.yml @@ -1,11 +1,11 @@ - - I change production qty with 3 Dozen Shelf 100cm. + I change production qty with 5 Dozen Shelf 100cm. - !python {model: change.production.qty}: | context.update({'active_id': ref('mrp_production_shelf100cm')}) - !record {model: change.production.qty, id: mrp_production_qty}: - product_qty: 3.0 + product_qty: 5.0 - !python {model: change.production.qty}: | self.change_prod_qty(cr, uid, [ref("mrp_production_qty")], context=context) @@ -14,38 +14,58 @@ - !python {model: mrp.production}: | order = self.browse(cr, uid, ref("mrp_production_shelf100cm")) - assert move.product_uom.id == ref("product.product_uom_dozen"), "UOM is not correspond." - assert move.product_qty == 3, "Qty is not changed." + assert order.product_uom.id == ref("product.product_uom_dozen"), "UOM is not correspond." + assert order.product_qty == 5, "Qty is not changed." - I compute the production order. - !python {model: mrp.production}: | order = self.browse(cr, uid, ref("mrp_production_shelf100cm"), context=context) - order.action_compute() + order.action_compute(context=context) - I check production lines after compute. - !python {model: mrp.production}: | order = self.browse(cr, uid, ref("mrp_production_shelf100cm"), context=context) - assert len(order.move_lines), "Production lines are not generated." - for line in order.move_lines: - if line.product_id.id == ref('product.product_product_assemblysection0'): - assert line.product_qty == (4.0*3.0*12.0), "Qty is not correspond." + assert len(order.product_lines) == 5, "Production lines are not generated proper." + sidepanel = False + woodlintelm = False + woodmm0 = False + woodmm10 = False + metalcleats = False + for line in order.product_lines: + if line.product_id.id == ref('product.product_product_sidepanel0'): #SIDEPAN 2 PCE + assert not sidepanel, "Production line is already generated for SIDEPAN." + assert line.product_qty == (2.0*12.0*5.0), "Qty is not correspond." assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond" - elif line.product_id.id == ref('product.product_product_sidepanel0'): - assert line.product_qty == (2.0*3.0*12.0), "Qty is not correspond." - assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond" - elif line.product_id.id == ref('product.product_product_metalcleats0'): - assert line.product_qty == (12.0*3.0*12.0), "Qty is not correspond." - assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond" - elif line.product_id.id == ref('product.product_product_rearpanelarm0'): - assert line.product_qty == (1.0*3.0*12.0), "Qty is not correspond." - assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond" - elif line.product_id.id == ref('product.product_product_shelf0'): - assert line.product_qty == (3.0*3.0*12.0), "Qty is not correspond." + sidepanel = True + elif line.product_id.id == ref('product.product_product_woodlintelm0'): #LIN40 4*0.25 Meter + assert not woodlintelm, "Production line is already generated for LIN40." + assert line.product_qty == (4*0.25*12.0*5.0), "Qty is not correspond." + assert line.product_uom.id == ref('product.product_uom_meter'), "UOM is not correspond" + woodlintelm = True + elif line.product_id.id == ref('product.product_product_woodmm0'): #WOOD002 0.25 m + assert not woodmm0, "Production line is already generated for WOOD002." + assert line.product_qty == (0.25*12.0*5.0), "Qty is not correspond." + assert line.product_uom.id == ref('product.product_uom_meter'), "UOM is not correspond" + woodmm0 = True + elif line.product_id.id == ref('product.product_product_metalcleats0'): #METC000 4*3 PCE + assert not metalcleats, "Production line is already generated for METC000." + assert line.product_qty == (4*3*12.0*5.0), "Qty is not correspond." assert line.product_uom.id == ref('product.product_uom_unit'), "UOM is not correspond" + metalcleats = True + elif line.product_id.id == ref('product.product_product_woodmm10'): #WOOD010 0.083*3 m + assert not woodmm10, "Production line is already generated for WOOD010." + assert line.product_qty == (0.083*3*12.0*5.0), "Qty is not correspond." + assert line.product_uom.id == ref('product.product_uom_meter'), "UOM is not correspond" + woodmm10 = True else: - assert_exception("Lines are not correspond.") + raise AssertionError('unknown order line: %s' % line) + assert sidepanel, "Production line is not generated for SIDEPAN." + assert woodlintelm, "Production line is not generated for LIN40." + assert woodmm0, "Production line is not generated for WOOD002." + assert metalcleats, "Production line is not generated for METC000." + assert woodmm10, "Production line is not generated for WOOD010." - I confirm the Production Order. - @@ -63,25 +83,27 @@ assert move.product_id.id == order.product_id.id, "Product is not correspond." assert move.product_uom.id == order.product_uom.id, "UOM is not correspond." assert move.product_qty == order.product_qty, "Qty is not correspond." - assert move.product_uos == order.product_uos, "UOS is not correspond." - assert move.product_uos_qty == order.product_uos_qty, "UOS qty is not correspond." + assert move.product_uos_qty == order.product_uos and order.product_uos_qty or order.product_qty, "UOS qty is not correspond." + if order.product_uos: + assert move.product_uos.id == order.product_uos.id, "UOS is not correspond." assert move.location_id.id == source_location_id, "Source Location is not correspond." assert move.location_dest_id.id == order.location_dest_id.id, "Destination Location is not correspond." routing_loc = None - if production.bom_id.routing_id and production.bom_id.routing_id.location_id: - routing_loc = production.bom_id.routing_id.location_id.id - + if order.bom_id.routing_id and order.bom_id.routing_id.location_id: + routing_loc = order.bom_id.routing_id.location_id.id + date_planned = order.date_planned for move_line in order.move_lines: for order_line in order.product_lines: - if line.product_id.type not in ('product', 'consu'): + if move_line.product_id.type not in ('product', 'consu'): continue if move_line.product_id.id == order_line.product_id.id: assert move_line.date == date_planned, "Planned date is not correspond in 'To consume line'." assert move_line.product_qty == order_line.product_qty, "Qty is not correspond in 'To consume line'." assert move_line.product_uom.id == order_line.product_uom.id, "UOM is not correspond in 'To consume line'." - assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or False, "UOS qty is not correspond in 'To consume line'." - assert move_line.product_uos == order_line.product_uos and order_line.product_uos.id or False, "UOS is not correspond in 'To consume line'." - assert move_line.location_id.id == routing_loc or production.location_src_id.id, "Source location is not correspond in 'To consume line'." + assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or order_line.product_qty, "UOS qty is not correspond in 'To consume line'." + if order_line.product_uos: + assert move_line.product_uos.id == order_line.product_uos.id, "UOS is not correspond in 'To consume line'." + assert move_line.location_id.id == routing_loc or order.location_src_id.id, "Source location is not correspond in 'To consume line'." assert move_line.location_dest_id.id == source_location_id, "Destination Location is not correspond in 'To consume line'." - @@ -95,37 +117,39 @@ routing_loc = None pick_type = 'internal' address_id = False - if production.bom_id.routing_id and production.bom_id.routing_id.location_id: - routing_loc = production.bom_id.routing_id.location_id + if order.bom_id.routing_id and order.bom_id.routing_id.location_id: + routing_loc = order.bom_id.routing_id.location_id if routing_loc.usage <> 'internal': pick_type = 'out' address_id = routing_loc.address_id and routing_loc.address_id.id or False routing_loc = routing_loc.id assert order.picking_id.type == pick_type, "Shipment should be Internal." - assert order.picking_id.address_id == address_id, "Shipment Address is not correspond with Adderss of Routing Location." - date_planned = production.date_planned + assert order.picking_id.address_id.id == address_id, "Shipment Address is not correspond with Adderss of Routing Location." + date_planned = order.date_planned for move_line in order.picking_id.move_lines: for order_line in order.product_lines: - if line.product_id.type not in ('product', 'consu'): + if move_line.product_id.type not in ('product', 'consu'): continue if move_line.product_id.id == order_line.product_id.id: assert move_line.date == date_planned, "Planned date is not correspond." assert move_line.product_qty == order_line.product_qty, "Qty is not correspond." assert move_line.product_uom.id == order_line.product_uom.id, "UOM is not correspond." - assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or False, "UOS qty is not correspond." - assert move_line.product_uos == order_line.product_uos and order_line.product_uos.id or False, "UOS is not correspond." - assert move_line.location_id.id == production.location_src_id.id, "Source location is not correspond." - assert move_line.location_dest_id.id == routing_loc or production.location_src_id.id, "Destination Location is not correspond." - procurement_ids = procurement.search(cr, uid, [('move_id','=',move_line.id)] + assert move_line.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or order_line.product_qty, "UOS qty is not correspond." + if order_line.product_uos: + assert move_line.product_uos.id == order_line.product_uos.id, "UOS is not correspond." + assert move_line.location_id.id == order.location_src_id.id, "Source location is not correspond." + assert move_line.location_dest_id.id == routing_loc or order.location_src_id.id, "Destination Location is not correspond." + procurement_ids = procurement.search(cr, uid, [('move_id','=',move_line.id)]) assert procurement_ids, "Procurement should be created for shipment line of raw materials." shipment_procurement = procurement.browse(cr, uid, procurement_ids[0], context=context) assert shipment_procurement.date_planned == date_planned, "Planned date is not correspond in procurement." assert shipment_procurement.product_id.id == order_line.product_id.id, "Product is not correspond in procurement." assert shipment_procurement.product_qty == order_line.product_qty, "Qty is not correspond in procurement." assert shipment_procurement.product_uom.id == order_line.product_uom.id, "UOM is not correspond in procurement." - assert shipment_procurement.product_uos_qty == order_line.product_uos and order_line.product_qty or False, "UOS qty is not correspond in procurement." - assert shipment_procurement.product_uos.id == order_line.product_uos and order_line.product_uos.id or False, "UOS is not correspond in procurement." - assert shipment_procurement.location_id.id == production.location_src_id.id, "Location is not correspond in procurement." + assert shipment_procurement.product_uos_qty == order_line.product_uos and order_line.product_uos_qty or order_line.product_qty, "UOS qty is not correspond in procurement." + if order_line.product_uos: + assert shipment_procurement.product_uos.id == order_line.product_uos.id, "UOS is not correspond in procurement." + assert shipment_procurement.location_id.id == order.location_src_id.id, "Location is not correspond in procurement." assert shipment_procurement.procure_method == order_line.product_id.procure_method, "Procure method is not correspond in procurement." @@ -181,8 +205,9 @@ - I check production order after produced. - - !assert {model: mrp.production, id: mrp_production_shelf100cm}: - - state == 'done' + !python {model: mrp.production}: | + order = self.browse(cr, uid, ref("mrp_production_shelf100cm")) + assert order.state == 'done', "Production order should be closed." - I print a "BOM Structure". diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index 4ae4a254d49..db4d6e77691 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -60,22 +60,11 @@ class mrp_product_produce(osv.osv_memory): } def do_produce(self, cr, uid, ids, context=None): - """ To check the product type - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID or list of IDs if we want more than one - @param context: A standard dictionary - @return: - """ - if context is None: - context = {} - prod_obj = self.pool.get('mrp.production') - production_ids = context.get('active_ids', []) - for data in self.browse(cr, uid, ids, context=context): - for production_id in production_ids: - prod_obj.action_produce(cr, uid, production_id, - data.product_qty, data.mode, context=context) + production_id = context.get('active_id', False) + assert production_id, "Production Id should be specified in context as a Active ID" + data = self.browse(cr, uid, ids[0], context=context) + self.pool.get('mrp.production').action_produce(cr, uid, production_id, + data.product_qty, data.mode, context=context) return {} mrp_product_produce() diff --git a/addons/product/product_demo.xml b/addons/product/product_demo.xml index 3aebec13715..99347667f80 100644 --- a/addons/product/product_demo.xml +++ b/addons/product/product_demo.xml @@ -442,6 +442,16 @@ product + + SPAN100 + produce + + + + Shelf Panel + product + + WOOD002 buy @@ -455,6 +465,19 @@ + + WOOD010 + buy + 7.0 + + + Wood 10mm + + + product + + + PROJ produce @@ -509,7 +532,7 @@ RPAN100 - buy + produce 10.0 @@ -548,7 +571,7 @@ RCK100 - buy + produce 5.0 From 678b8b44e44c3e5c40cc7a0a3e5d38eb644251e7 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Fri, 9 Dec 2011 19:08:18 +0530 Subject: [PATCH 39/44] [IMP] mrp: test case of yml to check workcenter lines after compute bzr revid: hmo@tinyerp.com-20111209133818-j5zioig52rtedm82 --- addons/mrp/mrp_demo.xml | 26 ++++++++++++++++++++------ addons/mrp/test/order_demo.yml | 7 +++++++ addons/mrp/test/order_process.yml | 31 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index 45958601f05..3e29930bae2 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -151,20 +151,23 @@ Short time assembly 2 + 5 long time assembly 5 + 15 - - + + - 0.5 - 3 - assembly main + processor + fan + Testing + 1 + 10 + @@ -173,6 +176,15 @@ 5 + + + + 0.5 + 3 + 5 + assembly main + processor + fan + + @@ -571,6 +583,7 @@ 1.0 +