I am using Odoo 15 and here is my code.
class StockMoveInherit(models.Model):
_inherit = 'stock.move'
def button_manufacture(self):
obj = self.env['mrp.production']
values = {
'product_id': self.product_id.id,
'product_qty': self.product_uom_qty,
'company_id': self.company_id.id,
'consumption': 'flexible',
'date_planned_start': datetime.datetime.now(),
'location_dest_id': self.location_dest_id.id,
'location_src_id': self.location_dest_id.id,
'product_uom_id': self.product_id.uom_id.id,
}
res = obj.create(values)
The object gets created. But the components are not loading/created for this product. I checked that my product has the BOM and depends upon other components. What am I mission here pls help. When I go and change the product from MO just created with this button, then the components get loaded. But it should be done when create method is triggered. If you need more info, let me know please.