Skip to Content
Menu
This question has been flagged

Hello,

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.

Avatar
Discard

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.

Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
2
Sep 19
5552
1
Jul 19
3056
0
Oct 22
1088
0
Oct 17
5517
1
Dec 24
56