Skip to content

Commit

Permalink
[FIX] document_page_approval: Smart buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgarRetes committed Oct 2, 2024
1 parent bbe2884 commit 7e5672f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions document_page/models/document_page_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def _get_diff(self, v1, v2):
context=True,
)

# TODO: Replace for _compute_display_name
def name_get(self):
return [(rec.id, "%s #%i" % (rec.page_id.name, rec.id)) for rec in self]
# # TODO: Replace for _compute_display_name
# def name_get(self):
# return [(rec.id, "%s #%i" % (rec.page_id.name, rec.id)) for rec in self]

@api.depends("page_id")
def _compute_display_name(self):
for rec in self:
rec.display_name = rec.id, "%s #%i" % (rec.page_id.name, rec.id)
# @api.depends("page_id")
# def _compute_display_name(self):
# for rec in self:
# rec.display_name = rec.id, "%s #%i" % (rec.page_id.name, rec.id)
24 changes: 12 additions & 12 deletions document_page_approval/views/document_page_approval.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,44 @@
type="object"
string="Send to Review"
class="oe_highlight"
invisible="not is_approval_required or not am_i_owner or state not in 'draft'"
invisible="not is_approval_required or not am_i_owner or state != 'draft'"
/>
<!-- approve if i am approver -->
<button
name="action_approve"
type="object"
string="Approve"
class="oe_highlight"
invisible="not is_approval_required or not am_i_approver or state not in 'draft' or state not in 'to approve'"
invisible="not is_approval_required or not am_i_approver or state != 'draft' or state != 'to approve'"
/>
<!-- approve if it's not required and i am owner -->
<button
name="action_approve"
type="object"
string="Approve"
class="oe_highlight"
invisible="is_approval_required or not am_i_owner or state not in 'draft' or state not in 'to approve'"
invisible="is_approval_required or not am_i_owner or state != 'draft' or state != 'to approve'"
/>
<!-- cancel if i am owner or approver -->
<button
name="action_cancel"
type="object"
string="Cancel"
invisible="not am_i_owner or not am_i_approver and state not in 'draft' or state not in 'to approve'"
invisible="(not am_i_owner or not am_i_approver) and (state != 'draft' or state != 'to approve')"
/>
<!-- reopen if i am owner or approver -->
<button
name="action_draft"
type="object"
string="Back to draft"
invisible="not am_i_owner or not am_i_approver and state not in 'cancelled'"
invisible="(not am_i_owner or not am_i_approver) and (state != 'cancelled')"
/>
<!-- cancel & reopen, if i am owner or approver -->
<button
name="action_draft"
type="object"
string="Back to draft"
invisible="not am_i_owner or not am_i_approver and state not in 'to approve'"
invisible="(not am_i_owner or not am_i_approver) and (state != 'to approve')"
/>
<field name="am_i_owner" invisible="1" />
<field name="am_i_approver" invisible="1" />
Expand All @@ -69,30 +69,30 @@
<field
name="approved_uid"
readonly="1"
invisible="state not in 'approved'"
invisible="state != 'approved'"
/>
<field
name="approved_date"
readonly="1"
invisible="state not in 'approved'"
invisible="state != 'approved'"
/>
</group>
</xpath>
<!-- Readonly fields -->
<field name="content" position="attributes">
<attribute name="readonly">state not in 'draft'
<attribute name="readonly">state != 'draft'
</attribute>
</field>
<field name="page_id" position="attributes">
<attribute name="readonly">state not in 'draft'
<attribute name="readonly">state != 'draft'
</attribute>
</field>
<field name="name" position="attributes">
<attribute name="readonly">state not in 'draft'
<attribute name="readonly">state != 'draft'
</attribute>
</field>
<field name="summary" position="attributes">
<attribute name="readonly">state not in 'draft'
<attribute name="readonly">state != 'draft'
</attribute>
</field>
<!-- Chatter -->
Expand Down

0 comments on commit 7e5672f

Please sign in to comment.