Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
7375 Näkymät

I have a special process that creates MO's based on BOM's from a task. 


In v10, this worked just fine.

mo_vals = {'product_id': product_id,
                           'bom_id': bom.id,                        
                           'product_uom_id': bom.product_uom_id.id,
                           'product_qty': bom.product_qty,
                           'sale_id'self.sale_id.id,
                           'task_id'self.id,
                            }
self.env['mrp.production'].create(mo_vals)

However in v13, when the MO is created, it does not populate the components (move_raw_ids)

It looks like the _onchange_bom_id that add the move_raw_ids on the MO is not being called when the record is being created. 

How do you call _onchange_bom_id at time of creation or even after?




Avatar
Hylkää
Tekijä Paras vastaus

For anyone else looking to do this, I was able to just manually call the onchange: Maybe not the right way, but it worked.


                mo_vals = {'product_id': product_id,
                           'bom_id': bom.id,                        
                           'product_uom_id': bom.product_uom_id.id,
                           'product_qty': bom.product_qty,
                           'sale_id': self.sale_id.id,
                           'task_id': self.id,
                           }
                mo = self.env['mrp.production'].sudo().create(mo_vals)
                mo._onchange_move_raw()


Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
jouluk. 19
2829
2
kesäk. 24
6330
2
maalisk. 24
1305
1
lokak. 23
1977
2
lokak. 23
2178