Skip to Content
Menu
This question has been flagged
1 Odpoveď
1106 Zobrazenia

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


Avatar
Zrušiť
Autor Best Answer

I found a solution!!!

In Odoo 17 CE in model hr.applicant this fields are defined like this:

salary_proposed_extra = fields.Char("Proposed Salary Extra", help="Salary Proposed by the Organisation, extra advantages", tracking=True, groups="hr_recruitment.group_hr_recruitment_user")

salary_expected_extra = fields.Char("Expected Salary Extra", help="Salary Expected by Applicant, extra advantages", tracking=True, groups="hr_recruitment.group_hr_recruitment_user")

salary_proposed = fields.Float("Proposed Salary", group_operator="avg", help="Salary Proposed by the Organisation", tracking=True, groups="hr_recruitment.group_hr_recruitment_user")

salary_expected = fields.Float("Expected Salary", group_operator="avg", help="Salary Expected by Applicant", tracking=True, groups="hr_recruitment.group_hr_recruitment_user")

My custom group does not have any reference to this group so, I decided to inherit this module and modify groups in these 4 fields setting parameter groups to False, and It worked. Hope other people find this helpful

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
1
aug 25
354
3
júl 25
2150
1
júl 25
665
1
júl 25
995
1
jún 25
2660