Skip to content

[18.0][FIX] document_page_approval: 'Back to draft' button visible in draft and approved states - #655

Open
miquelrosell99 wants to merge 1 commit into
OCA:18.0from
miquelrosell99:18.0-fix-back-to-draft-visibility
Open

miquelrosell99 wants to merge 1 commit into
OCA:18.0from
miquelrosell99:18.0-fix-back-to-draft-visibility

Conversation

@miquelrosell99

Copy link
Copy Markdown

Problem

In the history form view, the Back to draft button uses:

invisible="(not am_i_owner or not am_i_approver) and (state not in ('cancelled', 'to approve'))"

Because the two clauses are combined with and, the button is visible whenever the user is owner or approver — in any state, including draft and approved — and also for any user while the state is cancelled/to approve.

However, action_draft() raises a UserError unless the state is cancelled (document_page_approval/models/document_page_history.py:47), and requires the user to be owner or approver. So users routinely click a visible button that can only error out.

Fix

Align the visibility expression with the server-side checks:

invisible="(not am_i_owner and not am_i_approver) or state != 'cancelled'"

The button now shows only on cancelled revisions, for owners or approvers — matching the documented intent ("reopen if i am owner or approver") and the action_draft() constraints.

…revisions

The button was visible whenever the user was owner or approver, in any
state, and also for any user while the state was 'cancelled' or
'to approve'. action_draft() rejects anything but state 'cancelled',
so users got a UserError from a visible button.

Align the visibility with the server-side check: owner or approver,
and state 'cancelled'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:document_page_approval Module document_page_approval series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants