Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

button call function from another module in xml

By
omkar
on 3/28/14, 3:23 PM 1,681 views

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..

0
nikesh
On 5/26/16, 12:29 AM

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


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/28/14, 3:23 PM
Seen: 1681 times
Last updated: 5/26/16, 12:29 AM