Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ def cancel(self):
self.write({"state": "3_cancel"})
self._set_action_log("cancel")

def action_reset_to_draft(self):
self.write({"state": "1_draft"})
self._set_action_log("to_draft")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if we have 2 signers and one of them has already signed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etobella

In fact that module can not help unless I cancel and then set it back to draft and then I set to sent,

For example if a customer and employee, and employee has signed then this workfow will make the email to be sent to the customer or all customers who are in the sign request even if one of them has already signed.

In fact this is the point I made the other PR for, that is making email to be sent only to who did not sign.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then, all signers should be reseted back, isn't it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not at all, the point was just sending the email to who signed will not make sense because if the open the link they find themselves already signed.

but their signature is there not changed, other signers if they sign that will be append to former ones.

To avoid unnecessary emails I select the people who didn't sign to receive the notification email.

But I confirm no partner have to sign a document they already signed as this will make them upset and the purpose of this approach to facilitate to them not to annoy them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is mainly the issue...

Let me explain myself. If we cancel the sign.request, all signatures should be invalidated and we might need to start over again and sign everything again.

At least this is the way I see it. For me, the main goal here is to resend the request to the missing signers, wouldn't be better to do that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etobella
@victoralmau
and not change or update the state between canel, draft, and sent?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, no, the status should not be changed. As with other sections of Odoo, why shouldn't it be possible to resend an email to someone without having to change anything?

A button (only visible if sent and not signed) that does just that (sending an email) is the simplest and clearest interface.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact that first PR is doing the same functionality #89

Can we transition to and continue conversation as that button you suggest is there and I don't change the state there too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered at #89, the approach I propose is neither this PR nor the other one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make it closer there, don't worry.


@api.depends("signer_ids")
def _compute_signer_count(self):
for record in self:
Expand All @@ -250,7 +254,7 @@ def open_template(self):

def action_send(self, sign_now=False, message=""):
self.ensure_one()
if self.state != "1_draft":
if self.state not in ["1_draft", "0_sent"]:
return
self._set_action_log("validate")
self.state = "0_sent"
Expand All @@ -264,14 +268,16 @@ def action_send(self, sign_now=False, message=""):
engine="ir.qweb",
minimal_qcontext=True,
)
self.env["mail.thread"].message_notify(
body=render_result,
partner_ids=signer.partner_id.ids,
subject=_("New document to sign"),
subtype_id=self.env.ref("mail.mt_comment").id,
mail_auto_delete=False,
email_layout_xmlid="mail.mail_notification_light",
)
# send the message to partners who didn't sign only
if not signer.signed_on:
self.env["mail.thread"].message_notify(
body=render_result,
partner_ids=signer.partner_id.ids,
subject=_("New document to sign"),
subtype_id=self.env.ref("mail.mt_comment").id,
mail_auto_delete=False,
email_layout_xmlid="mail.mail_notification_light",
)

def action_send_signed_request(self):
self.ensure_one()
Expand Down Expand Up @@ -700,6 +706,7 @@ class SignRequestLog(models.Model):
("delete_field", "Delete field"),
("cancel", "Cancel"),
("configure", "Configure"),
("to_draft", "Reset to Draft"),
],
required=True,
readonly=True,
Expand Down
8 changes: 8 additions & 0 deletions sign_oca/views/sign_oca_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
confirm="You will cancel the request and all the accesses. Are you sure about it?"
groups="sign_oca.sign_oca_group_user"
/>
<button
string="Back to Draft"
type="object"
states="3_cancel"
name="action_reset_to_draft"
confirm="You will reset the request to draft. Are you sure about it?"
groups="sign_oca.sign_oca_group_user"
/>
<field
name="state"
widget="statusbar"
Expand Down