Override contextual groups when evaluating button states

Closes #15098
(grafted from 1326133b908292ff6e2964aa5a3c0682dd4ecd5c)

--HG--
branch : 8.0
This commit is contained in:
Cédric Krier
2026-09-30 08:15:23 +02:00
parent a8faeb02b5
commit 2584156da2
+11 -8
View File
@@ -771,14 +771,17 @@ class ModelView(Model):
ModelAccess.check(cls.__name__, 'write')
states = cls._buttons.get(func.__name__, {})
for state_name in {'invisible', 'readonly'} & states.keys():
state = _pyson_encoder.encode(states[state_name])
for record in records:
if _record_eval_pyson(record, state, encoded=True):
raise AccessButtonError(
gettext('ir.msg_button_state_record',
button=func.__name__,
**cls.__names__(record=record)))
with transaction.set_context(
groups=User.get_groups()):
for state_name in (
{'invisible', 'readonly'} & states.keys()):
state = _pyson_encoder.encode(states[state_name])
for record in records:
if _record_eval_pyson(record, state, encoded=True):
raise AccessButtonError(
gettext('ir.msg_button_state_record',
button=func.__name__,
**cls.__names__(record=record)))
if (transaction.user != 0) and check_access:
button_rules = Button.get_rules(