New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FW] Saas 17.1 hr fix same user creation mepe #162602
[FW] Saas 17.1 hr fix same user creation mepe #162602
Conversation
@mepe-odoo @sofiagvaladze cherrypicking of pull request #159860 failed. stdout:
stderr:
Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?). In the former case, you may want to edit this PR message as well. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
STEP TO REPRODUCE: ================== * Go on Employees application * Click on new * Set a name * Click on Hr Settings * Set Mitchell Admin as Related User * Click on backup cloud You will have a traceback about an sql constraint violation. Expected behaviour: =================== You should get a validation error with the sql constraint message. Similar behaviour: ================== When you try to do the same thing but with an existing employee you will have this validation error and not the traceback. Issue explanation: ================== To ensure that only one employee per company is linked to a user; the sql constraint user_uniq has been created. In the constraint only the fields user_id and company_id are checked. But the field user_id is realted to the resource's user_id and stored. So when creating employee; the record will be created without a user_id. Right after, a security rule linked to user_id will be checked. This ir.rule will trigger the computation of user_id. The safe_eval function will catch the validation error and instead of raising this validation error will raise a value error with the validation error as the message. And this, value error will raise the traceback. Resolution: =========== If the field user_id is pre-compute, the error will be raise during the creation and not during the security rule's check. Task: 3834561 X-original-commit: cce4207
a1d4154
to
87cfc6e
Compare
@robodoo r+ |
STEP TO REPRODUCE: ================== * Go on Employees application * Click on new * Set a name * Click on Hr Settings * Set Mitchell Admin as Related User * Click on backup cloud You will have a traceback about an sql constraint violation. Expected behaviour: =================== You should get a validation error with the sql constraint message. Similar behaviour: ================== When you try to do the same thing but with an existing employee you will have this validation error and not the traceback. Issue explanation: ================== To ensure that only one employee per company is linked to a user; the sql constraint user_uniq has been created. In the constraint only the fields user_id and company_id are checked. But the field user_id is realted to the resource's user_id and stored. So when creating employee; the record will be created without a user_id. Right after, a security rule linked to user_id will be checked. This ir.rule will trigger the computation of user_id. The safe_eval function will catch the validation error and instead of raising this validation error will raise a value error with the validation error as the message. And this, value error will raise the traceback. Resolution: =========== If the field user_id is pre-compute, the error will be raise during the creation and not during the security rule's check. closes #162602 Task: 3834561 X-original-commit: cce4207 Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com> Signed-off-by: Mélanie Peyrat (mepe) <mepe@odoo.com>
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: #159860