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