Odoo Help


ERROR: object has no attribute

on 7/10/15, 6:40 AM 2,338 views


I am trying to run this code:

models.execute_kw(DB, uid, PASS, 'hr.employee', 'attendance_action_change_jer', [state['id']], {})

I made a new class which inherits hr.employee from the hr_attendance.py
see: https://github.com/odoo/odoo/blob/8.0/addons/hr_attendance/hr_attendance.py

my new class:

class hr_employee(models.Model):

            _inherit = "hr.employee"

            # _name = "hr.employee"

            rfid_tag = fields.Char(string="RF ID tag for the user")

            def attendance_action_change_jer(self, cr, uid, ids, context=None):

                            _logger = logging.getLogger(__name__)

                            _logger.error('msg error')

but I got this error:

2015-07-10 10:30:26,989 11875 ERROR jeroen004 openerp.http: 'hr.employee' object has no attribute 'attendance_action_change_jer'

Traceback (most recent call last):

File "/home/luc/odoo/odoo/openerp/http.py", line 115, in dispatch_rpc

result = dispatch(method, params)

File "/home/luc/odoo/odoo/openerp/service/model.py", line 37, in dispatch

res = fn(db, uid, *params)

File "/home/luc/odoo/odoo/openerp/service/model.py", line 162, in execute_kw

return execute(db, uid, obj, method, *args, **kw or {})

File "/home/luc/odoo/odoo/openerp/service/model.py", line 113, in wrapper

return f(dbname, *args, **kwargs)

File "/home/luc/odoo/odoo/openerp/service/model.py", line 170, in execute

res = execute_cr(cr, uid, obj, method, *args, **kw)

File "/home/luc/odoo/odoo/openerp/service/model.py", line 159, in execute_cr

return getattr(object, method)(cr, uid, *args, **kw)

AttributeError: 'hr.employee' object has no attribute 'attendance_action_change_jer'

I have no idea what goes wrong. Why isnt my new attribute recognised? Even when I copy paste 'attendance_action_change_jer' in hr_attendance.py I get the same error.
Please help me.
Thanks in advance.

I think you have not given defination with new API that might be an issue. Because execute_kw is working with new model structure. So, please just give @api.multi decorator to your method. I hope it will resolve your issue.

Emipro Technologies Pvt. Ltd.
on 7/10/15, 8:13 AM



| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 7/10/15, 7:10 AM

Well, your class uses new api style ( models.Model) , while your method uses old style...

so, you have two possible solutions for your problem...

1. old style : you need to add on_change action in xml vew definition

2. new style : use @on_change decorator before actual method.. .

for both you can fin a lot of examples within the source code

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: 7/10/15, 6:40 AM
Seen: 2338 times
Last updated: 7/10/15, 8:13 AM