Odoo Help


AttributeError: 'account.invoice' object has no attribute 'init_fields'

Niko H
on 18-1-3 下午1:08 741 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):



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.


Niyas Raphy

--Niyas Raphy--
| 5 6 9
Calicut, 印度
--Niyas Raphy--

Odoo Techno Functionalist

Feel free to contact :  niyasraphyk@gmail.com

Niyas Raphy
On 18-1-3 下午10:50


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.


About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 18-1-3 下午1:08
Seen: 741 times
Last updated: 18-1-3 下午10:50