HI Friends.
I want to call a method for a button , the button is for one class and the action in another class.
How can I call that function with out using class inheritance..
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
HI Friends.
I want to call a method for a button , the button is for one class and the action in another class.
How can I call that function with out using class inheritance..
Hi omkar,
I think you have created a button in form or tree view of a model and trying to call a method in another model. The method for button should be defined in the model itself. To call method in another model, first you have to define a method in the model in form of which the button is created. Then you can call the method of another model from that method using object of the other model.
For example,
Suppose you have created a button in form view of sale order as:
<button name="method_a" type="object" string="Call Method" />
If you want to call a method 'method_b' in purchase order,
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
@api.multi
def method_b(self):
-------------------------
Then you have to define method 'method_a' in sale order as follows:
class SaleOrder(models.Model):
_inherit = 'sale.order'
@api.multi
def method_a(self):
self.env['purchase.order'].method_b()
---------------------------
Thanks & Regards
how to do this in odoo 12
Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!
Rekisteröidy