Merge pull request #2907 from expsa/samir-aladawi-fix-letters-sign
[FIX] exp_transaction_documents
This commit is contained in:
commit
3a2b4c2c93
|
|
@ -40,6 +40,7 @@ Managing Communications Transcations flows
|
|||
'wizard/archive_transaction.xml',
|
||||
'wizard/transaction_reply_wizard.xml',
|
||||
'wizard/reopen_transaction_wizard.xml',
|
||||
'wizard/sign_letter_transaction_view.xml',
|
||||
'email_templates/internal_templates.xml',
|
||||
'email_templates/incoming_templates.xml',
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,31 @@ class AttachmentRule(models.Model):
|
|||
created_from_system = fields.Boolean(readonly=True)
|
||||
signed_user_id = fields.Many2one('res.users')
|
||||
|
||||
|
||||
def action_sign_transaction(self):
|
||||
self.ensure_one()
|
||||
if self.internal_transaction_id:
|
||||
x = self.env['letters.letters'].search([('internal_transaction_id','=',self.internal_transaction_id.id)],limit=1)
|
||||
elif self.incoming_transaction_id:
|
||||
x = self.env['letters.letters'].search([('incoming_transaction_id','=',self.incoming_transaction_id.id)],limit=1)
|
||||
elif self.outgoing_transaction_id:
|
||||
x = self.env['letters.letters'].search([('outgoing_transaction_id','=',self.outgoing_transaction_id.id)],limit=1)
|
||||
|
||||
# self.signed_user_id = self.env.user.id
|
||||
# x.signed_user_id = self.env.user.id
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': 'Sign',
|
||||
'res_model': 'sign.letter.transaction',
|
||||
'view_mode': 'form',
|
||||
'view_id': self.env.ref('exp_transaction_documents.view_sign_letter_transaction_form').id,
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_letter_id': x.id ,
|
||||
'default_attachment_rule_id': self.id,
|
||||
},
|
||||
}
|
||||
|
||||
def action_signature(self):
|
||||
for rec in self:
|
||||
if rec.internal_transaction_id:
|
||||
|
|
|
|||
|
|
@ -122,3 +122,4 @@ access_forward_transaction_wizard,access_forward_transaction_wizard,model_forwar
|
|||
access_transaction_reply_wizard,access_transaction_reply_wizard,model_transaction_reply_wizard,base.group_user,1,1,1,1
|
||||
access_archive_transaction_wizard,access_archive_transaction_wizard,model_archive_transaction_wizard,base.group_user,1,1,1,1
|
||||
access_reopen_transaction_wizard,access_reopen_transaction_wizard,model_reopen_transaction_wizard,base.group_user,1,1,1,1
|
||||
access_sign_letter_transaction,access_sign_letter_transaction,model_sign_letter_transaction,base.group_user,1,1,1,1
|
||||
|
|
|
|||
|
|
|
@ -125,11 +125,16 @@
|
|||
<field name="date" readonly="True"/>
|
||||
<field name="description" required="False"/>
|
||||
<field name="file_save" filename="attachment_filename" widget="many2many_attachment_preview"/>
|
||||
<button name="action_signature"
|
||||
<button name="action_sign_transaction"
|
||||
type="object"
|
||||
string="Sign"
|
||||
class="btn-link"
|
||||
icon="fa-signature" attrs="{'invisible':['|',('signed','=',True), ('created_from_system', '!=', True)]}"/>
|
||||
<!-- <button name="action_signature"
|
||||
type="object"
|
||||
string="Sign"
|
||||
class="btn-link"
|
||||
icon="fa-signature" attrs="{'invisible':['|',('signed','=',True), ('created_from_system', '!=', True)]}"/> -->
|
||||
<field name="signed"/>
|
||||
<field name="external_drive_link" widget="url"/>
|
||||
<field name="attachment_filename" invisible="True"/>
|
||||
|
|
@ -242,11 +247,16 @@
|
|||
<field name="date" readonly="True"/>
|
||||
<field name="description" required="False"/>
|
||||
<field name="file_save" filename="attachment_filename" widget="many2many_attachment_preview"/>
|
||||
<button name="action_signature"
|
||||
<button name="action_sign_transaction"
|
||||
type="object"
|
||||
string="Sign"
|
||||
class="btn-link"
|
||||
icon="fa-signature" attrs="{'invisible':['|',('signed','=',True), ('created_from_system', '!=', True)]}"/>
|
||||
<!-- <button name="action_signature"
|
||||
type="object"
|
||||
string="Sign"
|
||||
class="btn-link"
|
||||
icon="fa-signature" attrs="{'invisible':['|',('signed','=',True), ('created_from_system', '!=', True)]}"/> -->
|
||||
<field name="signed"/>
|
||||
<field name="external_drive_link" widget="url"/>
|
||||
<field name="attachment_filename" invisible="True"/>
|
||||
|
|
@ -363,11 +373,16 @@
|
|||
<field name="date" readonly="True"/>
|
||||
<field name="description" required="False"/>
|
||||
<field name="file_save" filename="attachment_filename" widget="many2many_attachment_preview"/>
|
||||
<button name="action_signature"
|
||||
<button name="action_sign_transaction"
|
||||
type="object"
|
||||
string="Sign"
|
||||
class="btn-link"
|
||||
icon="fa-signature" attrs="{'invisible':['|',('signed','=',True), ('created_from_system', '!=', True)]}"/>
|
||||
<!-- <button name="action_signature"
|
||||
type="object"
|
||||
string="Sign"
|
||||
class="btn-link"
|
||||
icon="fa-signature" attrs="{'invisible':['|',('signed','=',True), ('created_from_system', '!=', True)]}"/> -->
|
||||
<field name="signed"/>
|
||||
<field name="external_drive_link" widget="url"/>
|
||||
<field name="attachment_filename" invisible="True"/>
|
||||
|
|
|
|||
|
|
@ -5,3 +5,4 @@ from . import forward_trasaction
|
|||
from . import transaction_reply_wizard
|
||||
from . import archive_transaction
|
||||
from . import reopen_transaction_wizard
|
||||
from . import sign_letter_transaction
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class SignLetterTransaction(models.TransientModel):
|
||||
_name = 'sign.letter.transaction'
|
||||
_description = 'Sign Letter Transaction'
|
||||
|
||||
letter_id = fields.Many2one('letters.letters', string="Letter", readonly=True)
|
||||
attachment_rule_id = fields.Many2one('cm.attachment.rule', string="Attachment Rule", readonly=True) # Update model name
|
||||
signature = fields.Binary(string='Signature', default=lambda self: self.env.user.sign_signature)
|
||||
|
||||
|
||||
def action_sign(self):
|
||||
self.ensure_one()
|
||||
# Make sure we have the necessary records
|
||||
if self.letter_id and self.signature:
|
||||
# Write the new signature to the letter
|
||||
self.letter_id.sudo().write({
|
||||
'new_signature': self.signature,
|
||||
'is_signed': True
|
||||
})
|
||||
|
||||
# Generate a new attachment (you must have action_generate_attachment() in letters.letters)
|
||||
new_attachment = self.letter_id.action_generate_attachment()
|
||||
if new_attachment:
|
||||
# Set the new attachment as signed
|
||||
attachment_record = self.env['cm.attachment.rule'].browse(new_attachment.id)
|
||||
if attachment_record:
|
||||
attachment_record.sudo().write({
|
||||
'signed': True
|
||||
})
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
def action_cancel(self):
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_sign_letter_transaction_form" model="ir.ui.view">
|
||||
<field name="name">sign.letter.transaction.form</field>
|
||||
<field name="model">sign.letter.transaction</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Sign Letter">
|
||||
<group>
|
||||
<field name="signature" widget="signature" required="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="action_sign" string="Sign" type="object" class="btn-primary"/>
|
||||
<button name="action_cancel" string="Cancel" type="object" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
|
|
@ -18,6 +18,7 @@ class Letters(models.Model):
|
|||
content = fields.Html(string="Content", tracking=True)
|
||||
signature = fields.Binary("Signature image",compute='compute_img',store=True)
|
||||
is_sign = fields.Boolean(string='Is Sign',readonly=True)
|
||||
is_signed = fields.Boolean(default=False, readonly=True)
|
||||
new_signature = fields.Binary("Signature image",readonly=True)
|
||||
transaction_type = fields.Selection([('internal', 'Internal'), ('outgoing', 'Outgoing'),
|
||||
('incoming', 'Incoming')], default='internal', string='Transaction Type', tracking=True)
|
||||
|
|
@ -166,7 +167,10 @@ class Letters(models.Model):
|
|||
letter_attachment = self.env['cm.attachment.rule'].search([(field_name, '=', res_id), ('created_from_system', '=', True)])
|
||||
if letter_attachment:
|
||||
letter_attachment.unlink()
|
||||
self.state = 'draft'
|
||||
self.write({
|
||||
'state': 'draft',
|
||||
'is_signed': False
|
||||
})
|
||||
|
||||
|
||||
class LettersTemp(models.Model):
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@
|
|||
</div>
|
||||
<br/>
|
||||
<br/>
|
||||
<div style="margin-top: 0px; page-break-inside: avoid;" dir="ltr">
|
||||
<div t-if="o.is_signed" style="margin-top: 0px; page-break-inside: avoid;" dir="ltr">
|
||||
<div style="margin-bottom: 10px; text-align: left;margin-left:25px;font-size:18px;">
|
||||
<span t-esc="o.signed_user_id.name"/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue