OCA / queue

Asynchronous Job Queue
GNU Affero General Public License v3.0
183 stars 460 forks source link

why run with with_delay can not get the new field。。。。???? ValueError: Invalid field 'job_title' on model 'hdjn_oa.employee_ext' #536

Closed lizhi2013 closed 1 year ago

lizhi2013 commented 1 year ago

Module

queue_job i then to run a script to create one record into a table with with_delay() interface[0].with_delay().cron_action_withpath( "wkf_add_user","hdjn_oa", datainput) in wkf_add_user: run the code like these: oadepartments_json = { 'employee': employee2[0].id, 'oadepartment': department2.id, 'job_title': each_record[0].job_title, } oadepartments = request.env['hdjn_oa.employee_ext'].with_user(auto_user[0].id).create(oadepartments_json) the fields job_title is just add , when i change the code like oadepartments_json = { 'employee': employee2[0].id, 'oadepartment': department2.id,
} that can run ok,when add 'job_title' this line ,then get the error 。 Invalid field 'job_title' on model 'hdjn_oa.employee_ext' but when i run the code in ctl that is ok:

datainput = {} kk = self.env['hr.employee'].sudo().search([("id","=",12251)], limit=1) datainput["each_record"] = kk[0] datainput["employee_id"] ='12251' datainput["name"] = '????' datainput["login"] = 'xxiao123'
interface[0].cron_action_withpath("wkf_add_user","hdjn_oa", datainput)

the error is like these why run with with_delay can not get the new field。。。。????

Exception:ValueError

Traceback (most recent call last): File "/mnt/extra-addons/queue_job/controllers/main.py", line 73, in runjob self._try_perform_job(env, job) File "/mnt/extra-addons/queue_job/controllers/main.py", line 32, in _try_perform_job job.perform() File "/mnt/extra-addons/queue_job/job.py", line 508, in perform self.result = self.func(*tuple(self.args), **self.kwargs) File "/mnt/extra-addons/hdjn_oa/models/interfaceclass.py", line 89, in cron_action_withpath uuidkey, datainput, uuidkey,self) File "/mnt/extra-addons/weidi_public/public/hdjn_oa_dynamicmodule/wkf_add_user.py", line 148, in runcommand oadepartments = request.env['hdjn_oa.employee_ext'].with_user(auto_user[0].id).create(oadepartments_json) File "", line 2, in create File "/usr/lib/python3/dist-packages/odoo/api.py", line 335, in _model_create_multi return create(self, [arg]) File "/usr/lib/python3/dist-packages/odoo/models.py", line 3767, in create raise ValueError("Invalid field %r on model %r" % (key, self._name)) ValueError: Invalid field 'job_title' on model 'hdjn_oa.employee_ext'

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Affected versions:

Steps to reproduce the behavior: 1. 2. 3.

Expected behavior A clear and concise description of what you expected to happen.

Additional context Add any other context about the problem here. (e.g. OS, Python version, ...)

simahawk commented 1 year ago

The description of the issue is messed up, pls fix it. Also it refers to custom models which are not reported here. Feel free to reopen when ready.