Merge pull request #5696 from expsa/khazraji_transaction

fix depends
This commit is contained in:
mohammed-alkhazrji 2025-12-10 18:45:31 +03:00 committed by GitHub
commit 4989de4f76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 19 deletions

View File

@ -5,7 +5,6 @@ class SignLetterTransaction(models.TransientModel):
_name = 'sign.letter.transaction' _name = 'sign.letter.transaction'
_description = '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 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) 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) name = fields.Char(default=lambda self: self.env.user.name, readonly=True)
@ -13,25 +12,8 @@ class SignLetterTransaction(models.TransientModel):
def action_sign(self): def action_sign(self):
self.ensure_one() 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): def action_cancel(self):
return {'type': 'ir.actions.act_window_close'} return {'type': 'ir.actions.act_window_close'}

View File

@ -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'}