콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
13603 화면

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.

아바타
취소
베스트 답변

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
아바타
취소
베스트 답변

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

아바타
취소
베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
0
3월 25
1874
0
1월 25
4125
1
8월 23
15711
change password 해결 완료
1
8월 23
14266
1
7월 23
11547