3
0
Fork 0

Allow employee user to set their own signature in preferences view

12.0
Pierre Verkest 2021-09-11 17:21:18 +02:00
parent c420cfb554
commit 95d4c6cd79
4 changed files with 18 additions and 2 deletions

View File

@ -36,4 +36,4 @@ class MailThread(models.AbstractModel):
msg_body += message
msg_body += '</li>'
msg_body += '</ul>'
self.message_post(body=msg_body, attachments=attachments)
self.sudo().message_post(body=msg_body, attachments=attachments)

View File

@ -24,3 +24,12 @@ class ResUsers(models.Model):
def write(self, vals):
self._track_signature(vals, 'digital_signature')
return super(ResUsers, self).write(vals)
def __init__(self, pool, cr):
super(ResUsers, self).__init__(pool, cr)
# duplicate list to avoid modifying the original reference
type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
type(self).SELF_WRITEABLE_FIELDS.extend(['digital_signature'])
# duplicate list to avoid modifying the original reference
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
type(self).SELF_READABLE_FIELDS.extend(['digital_signature'])

View File

@ -35,3 +35,10 @@ class TestSignatureTracking(common.SavepointCase):
current_messages = self.message_obj.search([])
message = current_messages - prev_messages
self.assertIn('Signature has been deleted.', message.body)
def test_self_signature_write(self):
"""Ensure users are able to set its own signature"""
user = self.env.ref('base.user_demo')
user = user.sudo(user)
user.write({"digital_signature": b'TEST'})
self.assertEqual(user.digital_signature, b'TEST')

View File

@ -23,7 +23,7 @@
<xpath expr="//field[@name='signature']" position="after">
<label for="digital_signature" string="Signature" class="oe_edit_only"/>
<h2>
<field name="digital_signature" widget="signature"/>
<field name="digital_signature" widget="signature" readonly="0" />
</h2>
</xpath>
</field>