2 In order to test mrp_subproduct with OpenERP, I create a bill of material with subproducts.
3 I make a production order, confirm it so stock moves for subproducts are generated.
5 I create a record for the product Chair.
7 !record {model: product.product, id: product_product_woodenchair0}:
10 procure_method: make_to_stock
11 supply_method: produce
13 uom_id: product.product_uom_unit
14 uom_po_id: product.product_uom_unit
15 property_stock_inventory: stock.location_inventory
16 property_stock_procurement: stock.location_procurement
17 property_stock_production: stock.location_production
19 I create a record for the product Wood.
21 !record {model: product.product, id: product_product_wood0}:
22 categ_id: product.cat1
24 procure_method: make_to_order
26 property_stock_inventory: stock.location_inventory
27 property_stock_procurement: stock.location_procurement
28 property_stock_production: stock.location_production
31 name: base.res_partner_maxtor
34 uom_id: product.product_uom_unit
35 uom_po_id: product.product_uom_unit
37 I create a record for the product Nails.
39 !record {model: product.product, id: product_product_nails0}:
40 categ_id: product.cat1
42 procure_method: make_to_order
44 property_stock_inventory: stock.location_inventory
45 property_stock_procurement: stock.location_procurement
46 property_stock_production: stock.location_production
49 name: base.res_partner_asus
52 uom_id: product.product_uom_unit
53 uom_po_id: product.product_uom_unit
55 I create a record for the product Table.
57 !record {model: product.product, id: product_product_woodentable0}:
58 categ_id: product.cat1
60 procure_method: make_to_stock
61 supply_method: produce
63 uom_id: product.product_uom_unit
64 uom_po_id: product.product_uom_unit
65 property_stock_inventory: stock.location_inventory
66 property_stock_procurement: stock.location_procurement
67 property_stock_production: stock.location_production
69 Now I create a bill of material for the product Wooden Chair.
71 !record {model: mrp.bom, id: mrp_bom_woodenchair0}:
72 company_id: base.main_company
74 product_efficiency: 1.0
75 product_id: product_product_woodenchair0
77 product_uom: product.product_uom_unit
81 - company_id: base.main_company
83 product_efficiency: 1.0
84 product_id: product_product_wood0
86 product_uom: product.product_uom_unit
90 - company_id: base.main_company
92 product_efficiency: 1.0
93 product_id: product_product_nails0
95 product_uom: product.product_uom_unit
100 - product_id: product_product_woodentable0
101 product_uom: product.product_uom_unit
103 subproduct_type: fixed
105 I create a production order for Wooden Chair.
107 !record {model: mrp.production, id: mrp_production_mo0}:
108 bom_id: mrp_bom_woodenchair0
109 company_id: base.main_company
110 date_planned: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S")
111 location_dest_id: stock.stock_location_stock
112 location_src_id: stock.stock_location_stock
114 product_id: product_product_woodenchair0
116 product_uom: product.product_uom_unit
119 I compute the data of production order.
121 !python {model: mrp.production}: |
122 self.action_compute(cr, uid, [ref("mrp_production_mo0")], {"lang": "en_US", "tz": False, "search_default_Current":
123 1, "active_model": "ir.ui.menu", "active_ids": [ref("mrp.menu_mrp_production_action")],
124 "active_id": ref("mrp.menu_mrp_production_action"), })
126 I confirm the production order.
128 !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_mo0}
130 Now I check the stock moves for the subproduct I created in the bill of material.
131 This move is created automatically when I confirmed the production order.
133 !python {model: stock.move}: |
134 move_id = self.search(cr, uid, [('product_id','=',ref('product_product_woodentable0'))])
135 assert move_id, 'No moves are created !'
137 I want to start the production so I force the reservation of products.
139 !python {model: mrp.production}: |
140 self.force_production(cr, uid, [ref("mrp_production_mo0")], {"lang": "en_US", "tz": False,
141 "search_default_Current": 1, "active_model": "ir.ui.menu", "active_ids":
142 [ref("mrp.menu_mrp_production_action")], "active_id": ref("mrp.menu_mrp_production_action"),
145 I start the production.
147 !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo0}
149 I consume and produce the Production of products.
151 I create record for selecting mode and quantity of products to produce.
153 !record {model: mrp.product.produce, id: mrp_product_produce0}:
155 mode: 'consume_produce'
157 I finish the production order.
159 !python {model: mrp.product.produce}: |
160 self.do_produce(cr, uid, [ref("mrp_product_produce0")], {"lang": "en_US", "tz":
161 False, "search_default_Current": 1, "active_model": "mrp.production", "active_ids":
162 [ref("mrp_production_mo0")], "active_id": ref("mrp_production_mo0"), })
164 I see that stock moves of Wood and Nails including Wooden Table are done now.
166 !python {model: stock.move}: |
167 move_ids = self.search(cr, uid, [('product_id','in',[ref("product_product_woodentable0"),ref("product_product_wood0"),ref("product_product_nails0")])])
168 moves = self.browse(cr, uid, move_ids)
169 assert all(move.state == 'done' for move in moves), 'Moves are not done!'