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.
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:
- If you have two different class in two different file than import that file or class
- Get an instance of that class instead of directly calling to the web_login function from that class
- After getting instance of the class, use that instance to call the method
0 Comments