diff --git a/odex25_transactions/exp_transaction_documents/wizard/sign_letter_transaction.py b/odex25_transactions/exp_transaction_documents/wizard/sign_letter_transaction.py index b526a6bb6..3ab59a319 100644 --- a/odex25_transactions/exp_transaction_documents/wizard/sign_letter_transaction.py +++ b/odex25_transactions/exp_transaction_documents/wizard/sign_letter_transaction.py @@ -5,7 +5,6 @@ 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) name = fields.Char(default=lambda self: self.env.user.name, readonly=True) @@ -13,25 +12,8 @@ class SignLetterTransaction(models.TransientModel): 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.with_context(is_sign=True).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'} + return def action_cancel(self): return {'type': 'ir.actions.act_window_close'} \ No newline at end of file diff --git a/odex25_transactions/exp_transation_letters/models/letter.py b/odex25_transactions/exp_transation_letters/models/letter.py index 50c3206d8..9e5ea1534 100644 --- a/odex25_transactions/exp_transation_letters/models/letter.py +++ b/odex25_transactions/exp_transation_letters/models/letter.py @@ -227,3 +227,34 @@ class AttachmentRule(models.Model): }, } + +class SignLetterTransaction(models.TransientModel): + _inherit = 'sign.letter.transaction' + + letter_id = fields.Many2one( + 'letters.letters', + string="Letter", + readonly=True + ) + + 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.with_context(is_sign=True).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'} \ No newline at end of file