Skip to Content
Menu
This question has been flagged
3 Replies
12772 Views

I'm trying to expand the account.invoice model with functions and fields but seem to be unable because I keep getting this error.

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/odoo-8.0-py2.7.egg/openerp/http.py", line 544, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/local/lib/python2.7/dist-packages/odoo-8.0-py2.7.egg/openerp/http.py", line 581, in dispatch
    result = self._call_function(**self.params)
  File "/usr/local/lib/python2.7/dist-packages/odoo-8.0-py2.7.egg/openerp/http.py", line 317, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/odoo-8.0-py2.7.egg/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/odoo-8.0-py2.7.egg/openerp/http.py", line 314, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/local/lib/python2.7/dist-packages/odoo-8.0-py2.7.egg/openerp/http.py", line 810, in __call__
    return self.method(*args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/odoo-8.0-py2.7.egg/openerp/http.py", line 410, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo_server/addons/web/controllers/main.py", line 948, in call_button
    action = self._call_kw(model, method, args, {})
  File "/opt/odoo/odoo_server/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
AttributeError: 'account.invoice' object has no attribute 'init_fields'


I have this in my models.py:

class invoice_fields(models.Model):  

    _inherit = "account.invoice";

    def init_fields(self):

        self.ExtendModel();


.....

I try to call that function from the templates.xml file with a button using type="object" and name="init_fields".

As you can see I have inherited account.invoice but for some reason my function isn't working. What could be the problem?


I'm using Odoo 8.0.

Avatar
Discard
Best Answer

Hi, Niko

Due to the wrong syntax you are getting this issue. 

Kindly update your code like below,

class invoice_fields(models.Model):  
    _inherit = "account.invoice"

    def init_fields(self):
        self.ExtendModel()


Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited
Avatar
Discard
Best Answer

Hi,

As you have given written the function in the account.invoice model,  what we have to do next is that , check and ensure that the py file contain the function is called in the init file.

Thanks

Avatar
Discard
Best Answer

_inherit = "account.invoice"  instead of _inherit = "account.invoice";

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 23
12546
1
Aug 23
11041
1
Jul 23
7222
4
Apr 23
8676
2
Feb 23
17590