In my custom model i have button when i clicking that it will generate MO also i want to perform that the onchange function in the product_id or the bom_id , is it possible
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Financeiro
- Inventário
- PoS
- Project
- MRP
Esta pergunta foi sinalizada
1
Responder
2559
Visualizações
Hi,
You can call the function from anywhere using it’s object.
suppose you have a onchange function defined on product model then you can call it as below:
self.product_id._onchange_function()
Hope this will help you
Thanks
Está gostando da discussão? Não fique apenas lendo, participe!
Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!
Inscreva-sePublicações relacionadas | Respostas | Visualizações | Atividade | |
---|---|---|---|---|
|
2
ago. 23
|
2186 | ||
|
2
mai. 23
|
2393 | ||
|
0
jun. 22
|
1427 | ||
|
3
mar. 24
|
2833 | ||
|
1
mai. 23
|
2125 |
@Mehjabin Farsana, that didi'nt work, i want to perform the function in on change, ex;
@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