Odoo Help


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


ERROR: object has no attribute

on 7/10/15, 6:40 AM 779 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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 7/10/15, 6:40 AM
Seen: 779 times
Last updated: 7/10/15, 8:13 AM