Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
2241 Weergaven

@api.onchange('product_id', 'picking_type_id', 'company_id')
def _onchange_product_id(self):
print(1)
""" Finds UoM of changed product. """
if not self.product_id:
self.bom_id = False
elif not self.bom_id or self.bom_id.product_tmpl_id != self.product_tmpl_id or (self.bom_id.product_id and self.bom_id.product_id != self.product_id):
picking_type_id = self._context.get('default_picking_type_id')
print(picking_type_id)
picking_type = picking_type_id and self.env['stock.picking.type'].browse(picking_type_id)
bom = self.env['mrp.bom']._bom_find(self.product_id, picking_type=picking_type, company_id=self.company_id.id, bom_type='normal')[self.product_id]
print(bom)
if bom:
print('pqwewe')
self.bom_id = bom.id
self.product_qty = self.bom_id.product_qty
self.product_uom_id = self.bom_id.product_uom_id.id
else:
self.bom_id = False
self.product_uom_id = self.product_id.uom_id.id
I want to perform the all function, but i only get the print(1), not working the other things

Avatar
Annuleer
Beste antwoord

Hi,

Please check the value of self.product_id and bom.You can use print to check if the conditions are satisfied. 

The conditions may not be satisfied, and that might be the reason the other prints are not working.


Avatar
Annuleer
Beste antwoord

Hi, 

You can watch following video for this:

https://youtu.be/ezH3ql5Dmx4

Thanks

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
mei 23
2447
1
apr. 23
2621
0
jun. 22
1489
3
mrt. 24
2952
1
mei 23
2181