2 In order to test the sale_mrp module in OpenERP, I start by creating a new product 'Slider Mobile'
4 I define product category Mobile Products Sellable.
6 !record {model: product.category, id: product_category_allproductssellable0}:
7 name: Mobile Products Sellable
9 I define product category Mobile Services.
11 !record {model: product.category, id: product_category_16}:
14 I define product template for Slider Mobile.
16 !record {model: product.template, id: product_template_slidermobile0}:
17 categ_id: product_category_allproductssellable0
23 uom_id: product.product_uom_unit
24 uom_po_id: product.product_uom_unit
26 I define a product Slider Mobile
28 !record {model: product.product, id: product_product_slidermobile0}:
29 categ_id: product_category_allproductssellable0
36 name: base.res_partner_2
41 uom_id: product.product_uom_unit
42 uom_po_id: product.product_uom_unit
44 I add the routes manufacture and mto to the product
46 !python {model: product.product}: |
47 route_warehouse0_manufacture = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).manufacture_pull_id.route_id.id
48 route_warehouse0_mto = self.pool.get('stock.warehouse').browse(cr, uid, ref('stock.warehouse0')).mto_pull_id.route_id.id
49 self.write(cr, uid, ref('product_product_slidermobile0'), { 'route_ids': [(6, 0, [route_warehouse0_mto,route_warehouse0_manufacture])]}, context=context)
51 I create a Bill of Material record for Slider Mobile
53 !record {model: mrp.bom, id: mrp_bom_slidermobile0}:
54 company_id: base.main_company
56 product_efficiency: 1.0
57 product_tmpl_id: product_product_slidermobile0_product_template
58 product_id: product_product_slidermobile0
60 product_uom: product.product_uom_unit
64 I create a sale order for product Slider mobile
66 !record {model: sale.order, id: sale_order_so0}:
67 client_order_ref: ref1
68 date_order: !eval time.strftime('%Y-%m-%d')
73 product_uom: product.product_uom_unit
74 product_uom_qty: 500.0
77 product_id: product_product_slidermobile0
78 product_uos_qty: 500.0
80 partner_id: base.res_partner_4
81 partner_invoice_id: base.res_partner_address_7
82 partner_shipping_id: base.res_partner_address_7
83 picking_policy: direct
84 pricelist_id: product.list0
86 I confirm the sale order
88 !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
90 I verify that a procurement has been generated for sale order
92 !python {model: procurement.order}: |
93 sale_order_obj = self.pool.get('sale.order')
94 so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
95 proc_ids = self.search(cr, uid, [('origin','=',so.name)])
96 assert proc_ids, 'No Procurements!'
98 Then I click on the "Run Procurement" button
100 !python {model: procurement.order}: |
101 sale_order_obj = self.pool.get('sale.order')
102 so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
103 proc_ids = self.search(cr, uid, [('origin','like',so.name)])
104 self.run(cr, uid, proc_ids)
106 I verify that a procurement state is "running"
108 !python {model: procurement.order}: |
109 sale_order_obj = self.pool.get('sale.order')
110 so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
111 proc_ids = self.search(cr, uid, [('origin','like',so.name)])
112 # Check that all procurement are running
113 for procu in self.browse(cr,uid,proc_ids,context=context):
114 assert procu.state == u'running', 'Procurement with id %d should be with a state "running" but is with a state : %s!' %(procu.id,procu.state)
116 I verify that a manufacturing order has been generated, and that its name and reference are correct
118 !python {model: sale.order}: |
119 mnf_obj = self.pool.get('mrp.production')
120 so = self.browse(cr, uid, ref("sale_order_so0"))
121 mnf_id = mnf_obj.search(cr, uid, [('origin','like',so.name)])
122 assert mnf_id, 'Manufacturing order has not been generated'
123 mo = mnf_obj.browse(cr, uid, mnf_id)[0]
124 assert mo.sale_name == so.name, 'Wrong Name for the Manufacturing Order. Expected %s, Got %s' % (so.name, mo.name)
125 assert mo.sale_ref == so.client_order_ref, 'Wrong Sale Reference for the Manufacturing Order'