diff --git a/addons/hr_recruitment_survey/__init__.py b/addons/hr_recruitment_survey/__init__.py index f2cd96d8c83..40820b4f849 100644 --- a/addons/hr_recruitment_survey/__init__.py +++ b/addons/hr_recruitment_survey/__init__.py @@ -3,3 +3,19 @@ from . import models from . import wizard from . import controllers + + +def _correct_survey_rule(env): + # if hr_appraisal_survey is alrady installed we need to override survey.survey_user_input_rule_survey_user_read + # because otherwise domain that is set in hr_appraisal_survey is wiped out + if env['ir.module.module'].search([('name', '=', 'hr_appraisal_survey'), ('state', '=', 'installed')]): + record = env.ref("survey.survey_user_input_rule_survey_user_read", raise_if_not_found=False) + if record: + record.domain_force = [('applicant_id', '=', False), ('survey_id.survey_type', '!=', 'appraisal')] + + +def uninstall_hook(env): + rule = env.ref("survey.survey_user_input_rule_survey_user_read", raise_if_not_found=False) + if rule: + domain = "('applicant_id', '=', False)" + rule.domain_force = rule.domain_force.replace(domain, "(1, '=', 1)") diff --git a/addons/hr_recruitment_survey/__manifest__.py b/addons/hr_recruitment_survey/__manifest__.py index 9bc22bb22c0..508a89a946b 100644 --- a/addons/hr_recruitment_survey/__manifest__.py +++ b/addons/hr_recruitment_survey/__manifest__.py @@ -22,4 +22,6 @@ to allow you to define interviews for different jobs. 'data/hr_job_demo.xml', ], 'license': 'LGPL-3', + 'post_init_hook': '_correct_survey_rule', + 'uninstall_hook': 'uninstall_hook', }