I am creating some modules that inherit from hr.job and hr.applicant, basically what they do is that when a user applies to a record in hr.job, the record is created in hr.applicant and redirected to the form of the record that was just created.
When applying, the record is created in hr.applicant with all the data, but when rendering the view for the form, I get an error for the Grant Applicant role that says the following:
UncaughtPromiseError > OwlError
Uncaught Promise > An error occured in the owl lifecycle (see this Error's "cause" property)
OwlError: An error occured in the owl lifecycle (see this Error's "cause" property)
Error: An error occured in the owl lifecycle (see this Error's "cause" property)
at handleError (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:916:101)
at App.handleError (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:1551:29)
at Fiber._render (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:941:19)
at Fiber.render (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:939:6)
at ComponentNode.initiateRender (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:1008:47)
Caused by: EvalError: Can not evaluate python expression: (bool(not salary_expected_extra))
Error: Name 'salary_expected_extra' is not defined
EvalError: Can not evaluate python expression: (bool(not salary_expected_extra))
Error: Name 'salary_expected_extra' is not defined
at evaluateExpr (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:3058:54)
at FormRenderer.evaluateBooleanExpr (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:3061:8)
at FormRenderer.slot25 (eval at compile (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:1503:374), <anonymous>:170:26)
at callSlot (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:1109:25)
at InnerGroup.template (eval at compile (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:1503:374), <anonymous>:56:42)
at Fiber._render (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:940:96)
at Fiber.render (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:939:6)
at ComponentNode.initiateRender (http://localhost:8888/web/assets/d35eeae/web.assets_web.min.js:1008:47)
However, if I also assign the same user the role of administrator or interviewer for the recruitment modules, the error disappears. What can I do?
Here is the code that generates the record in hr.applicant after the user clicks on the corresponding button in the kanban view of hr.job:
def action_create_application(self):
current_user = self.env.user
applicant_obj = self.env['hr.applicant']
for job in self:
existing_applicant = applicant_obj.search([
('job_id', '=', job.id),
('partner_id', '=', current_user.partner_id.id)
])
if existing_applicant:
raise UserError('Already applied for this Grant')
else:
applicant = applicant_obj.create({
'name': 'Application of %s to %s' % (current_user.partner_id.name, job.name),
'partner_name': current_user.partner_id.name,
'email_from': current_user.partner_id.email,
'partner_id': current_user.partner_id.id,
'job_id': job.id,
})
return {
'type': 'ir.actions.act_window',
'res_model': 'hr.applicant',
'view_mode': 'form',
'res_id': applicant.id,
'target': 'current',
}
Also this is my inherited view form:
<record id="view_hr_applicant_grant_applicant_form" model="ir.ui.view">
<field name="name">hr.applicant.grant.applicant.form</field>
<field name="model">hr.applicant</field>
<field name="inherit_id" ref="hr_recruitment.hr_applicant_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='stage_id']" position="replace">
<field name="state" widget="statusbar" options="{'clickable': '1', 'fold_field': 'fold'}"
invisible="not active and not emp_id"/>
</xpath>
<xpath expr="//field[@name='name']" position="attributes">
<attribute name="placeholder">Insert here a subject for your application</attribute>
</xpath>
</field>
</record>
If you need more information let me know. Thanks