Search Here

Invoke controller class function from another controller in odoo

 In this article you will learn how to resolve unbound method web_login() must be called with Home instance as first argument (got nothing instead) in Odoo. This issue related to Odoo web controllers.

unbound method web_login() must be called with instance as first argument (got nothing instead),Invoke controller function from another controller in odoo

Call controller class method from another controller class


The below issue raises when we are trying to call one controller class method that is inherited from some another controller class, from another controller class in Odoo. For example we have two controllers with class name InheritedHome and MyCustomClass. InheritedHome Class has some method named web_login and we are trying to call that web_login() function from MyCustomClass controller class.

TypeError: unbound method web_login() must be called with Extension_Home instance as first argument (got nothing instead)

To resolve above issue you must know about bound method. A bound method or function is always attached to an instance of an object. The error occur because you are calling the method on class instead of on an instance. Follow below steps to resolve the issue:

  1. If you have two different class in two different file than import that file or class
  2. Get an instance of that class instead of directly calling to the web_login function from that class
  3. After getting instance of the class, use that instance to call the method

call-controller-function-from-another-controller.py 


Post a Comment

0 Comments