0

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.

Dipen Shah
  • 2,396
  • 2
  • 9
  • 21
user3606682
  • 1,945
  • 3
  • 17
  • 24
  • As my experience, onchange function is not working when import data or create model with code. I think you should find another way like adding in create function or something. – Neural Nov 08 '21 at 08:10
  • Got your point @Neural thanks for your response. As alternate I took the id from res and created the dependant components with code. Thanks – user3606682 Nov 09 '21 at 11:09

0 Answers0