Skip to content

Commit

Permalink
[FIX] sign_oca: Duplicated Sign button in request
Browse files Browse the repository at this point in the history
Unify to_sign and signer_is_allow_signature fields which had the same purpose
  • Loading branch information
PauBForgeFlow committed Mar 7, 2024
1 parent 812e8b5 commit f38c83c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 37 deletions.
2 changes: 1 addition & 1 deletion sign_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Sign Oca
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9b44db521a46b44af9040d779df81183027a35d38c9ee7c725e66918f255d14a
!! source digest: sha256:360519e57a3d8bc0738d74da98d8cda06d99420d9abc1b415ed14fea98afc397
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion sign_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"sign_oca/static/src/components/sign_oca_configure/sign_oca_configure.xml",
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.xml",
"sign_oca/static/src/elements/elements.xml",
"sign_oca/static/src/elements/systray.xml"
"sign_oca/static/src/elements/systray.xml",
"sign_oca/static/src/scss/sign_oca.scss",
"sign_oca/static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.esm.js",
"sign_oca/static/src/elements/text.esm.js",
Expand Down
28 changes: 7 additions & 21 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,32 +91,27 @@ class SignOcaRequest(models.Model):
comodel_name="sign.oca.request.signer",
compute="_compute_signer_from_user_partner",
)
signer_is_allow_signature = fields.Boolean(
compute="_compute_signer_is_allow_signature"
)

@api.depends_context("uid")
def _compute_signer_from_user_partner(self):
user = self.env.user
for item in self:
for record in self:
signer = fields.first(
item.signer_ids.filtered(
record.signer_ids.filtered(
lambda x: x.partner_id == user.partner_id.commercial_partner_id
)
)
item.signer_from_user_partner = signer
record.signer_from_user_partner = signer

@api.depends(
"state",
"signer_from_user_partner",
"signer_from_user_partner.is_allow_signature",
)
def _compute_signer_is_allow_signature(self):
for item in self:
signer = item.signer_from_user_partner
item.signer_is_allow_signature = (
signer.is_allow_signature if signer else False
)
def _compute_to_sign(self):
for record in self:
signer = record.signer_from_user_partner
record.to_sign = signer.is_allow_signature if signer else False

def action_signer_sign_url(self):
self.ensure_one()
Expand Down Expand Up @@ -263,15 +258,6 @@ def action_send(self, sign_now=False, message=""):
email_layout_xmlid="mail.mail_notification_light",
)

@api.depends("signer_ids.role_id", "signatory_data")
@api.depends_context("uid")
def _compute_to_sign(self):
for record in self:
record.to_sign = record.signer_ids.filtered(
lambda r: r.partner_id.id == self.env.user.partner_id.id
and not r.signed_on
).mapped("role_id")

def _check_signed(self):
self.ensure_one()
if self.state != "sent":
Expand Down
2 changes: 1 addition & 1 deletion sign_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sign Oca</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9b44db521a46b44af9040d779df81183027a35d38c9ee7c725e66918f255d14a
!! source digest: sha256:360519e57a3d8bc0738d74da98d8cda06d99420d9abc1b415ed14fea98afc397
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sign/tree/16.0/sign_oca"><img alt="OCA/sign" src="https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sign-16-0/sign-16-0-sign_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sign&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to create documents for signature inside Odoo using OWL.</p>
Expand Down
20 changes: 7 additions & 13 deletions sign_oca/views/sign_oca_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<form create="0">
<header>
<button
name="sign"
string="Sign"
name="action_signer_sign_url"
class="btn btn-primary"
type="object"
string="Sign"
attrs="{'invisible': [('to_sign', '=', False)]}"
attrs="{'invisible': ['|',('to_sign', '=', False), ('state', '!=', 'sent')]}"
/>
<field name="to_sign" invisible="1" />
<button
Expand All @@ -32,12 +32,6 @@
confirm="You will cancel the request and all the accesses. Are you sure about it?"
groups="sign_oca.sign_oca_group_user"
/>
<button
string="Sign"
type="object"
name="action_signer_sign_url"
attrs="{'invisible': [('signer_is_allow_signature', '=', False)]}"
/>
<field
name="state"
widget="statusbar"
Expand Down Expand Up @@ -81,7 +75,6 @@
/>
</div>
<field name="active" invisible="1" />
<field name="signer_is_allow_signature" invisible="1" />
<widget
name="web_ribbon"
title="Fully Signed"
Expand Down Expand Up @@ -221,10 +214,11 @@
<field name="record_ref" />
<field name="state" readonly="1" invisible="1" />
<button
name="sign"
type="object"
string="Sign"
attrs="{'invisible': [('to_sign', '=', False)]}"
name="action_signer_sign_url"
class="btn btn-primary"
type="object"
attrs="{'invisible': ['|',('to_sign', '=', False), ('state', '!=', 'sent')]}"
/>
<field name="to_sign" invisible="1" />
</tree>
Expand Down

0 comments on commit f38c83c

Please sign in to comment.