diff options
| author | Lucas Lefèvre <lul@odoo.com> | 2019-06-05 07:58:37 +0000 |
|---|---|---|
| committer | RomainLibert <rli@odoo.com> | 2019-06-07 13:10:05 +0000 |
| commit | 92d041946794653f09849437879ba8214b00f876 (patch) | |
| tree | d2089e4656a76f206443b8b710dc4715e9e22f17 /addons/web/static/src/js/fields/basic_fields.js | |
| parent | bd38c693f14a29eb1c66c649d76670a850538e33 (diff) | |
[FIX] hr_holidays: Display approve button when needed
This commit reverts commit 492764c
*Note for forward port*
This commit will conflict with 76ee0af. Keep this version.
TL;DR: the fix had unintended effects and the original problem has been
fixed by b5c2004 in the mean time.
Why the original commit?
------------------------
To know if the current user has the rights to approve/delete a leave,
two boolean fields are computed (respectively `can_approve`
and `can_reset`). Associated buttons are shown in the form view according to
the field values.
In the compute methods, the `check_approval_update(state)` method is called.
This method checks various conditions, including `ir.rules` by calling the ORM
method `self.check_access_rule('write')`. If one condition or one `ir.rule`
is not met, an Error is raised.
If the method raises, the user does not have the rights.
The exception is catched and the field `can_approve|reset` is set to False.
However, an unexpected behaviour happens when fields are re-computed
in the context of an onchange. In an onchange, `self.ids` is an empty list.
When checking ir.rules, the `_filter_access_rules()` method is used
to retrieve valid records in self by checking every record against ir.rules.
If some records are not in the valid set, they are considered invalid and an
exception is raised.
But because self.ids is empty, no record is actually checked and therefore
no record is valid.
=> in an onchange it always raises an AccessError and the users is considered
as not having the rights to approve nor refuse a leave as soon as an
onchange has been triggered. Thus associated buttons does not appear.
The original commit fixed the problem by preventing checking the rules
when in an onchange.
In the mean time, the root cause of the problem has been fixed by b5c2004.
Why revert?
-----------
While commit 492764c allowed HR users and Team leaders to approve
after an onchange, it had the unintended effect to
show the "Approve" and "Refuse" buttons to other users.
In summary:
- With commit 492764c: buttons are shown more than necessary
(which is confusing to users who don't actually the rights
to approve)
- Without: Thanks to b5c2004, the original problem no longer exists.
Users with access rights always see buttons. Users without never see
buttons.
closes odoo/odoo#33894
Signed-off-by: Romain Libert (rli) <rli@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
0 files changed, 0 insertions, 0 deletions
