[FIX] hr_recruitment_survey: correct the rule

The survey.survey_user_input_rule_survey_user_read rule is
override in both hr_appraisal_survey and in hr_recruitment_survey.

The problem arises when both modules are installed. If so, the domain
is taken from the module that is installed the last.

This should not be case, instead domain should be combined.

On top of it, the domain is not corrected when the app is unistalled.
This commit fixes that too

task - 3597033

closes odoo/odoo#163138

X-original-commit: 5d4b5175855041efd6174fe5e35f06ede3b62818
Related: odoo/enterprise#61363
Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
This commit is contained in:
sofiagvaladze
2024-04-25 11:21:53 +00:00
parent a1ee8f4d94
commit bf696b054e
2 changed files with 18 additions and 0 deletions
+16
View File
@@ -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)")
@@ -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',
}