Merge pull request #3380 from expsa/dev_odex25_transactions

Dev odex25 transactions
This commit is contained in:
kchyounes19 2025-06-01 15:51:53 +01:00 committed by GitHub
commit b1df39a13a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 35 deletions

View File

@ -22,7 +22,7 @@ class SignLetterTransaction(models.TransientModel):
})
# Generate a new attachment (you must have action_generate_attachment() in letters.letters)
new_attachment = self.letter_id.action_generate_attachment()
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)

View File

@ -53,6 +53,7 @@ class Letters(models.Model):
tracking=True
)
job_name = fields.Char(string="Job Name", store=True)
@api.depends('transaction_type', 'name')
def compute_img(self):
employee_id = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
@ -119,6 +120,13 @@ class Letters(models.Model):
""" this method called from button action in view xml """
# generate pdf from report, use report's id as reference
for record in self:
if self.env.context.get('is_sign'):
employee = self.env['hr.employee'].search([('user_id', '=', self.env.user.id)], limit=1)
record.job_name = employee.job_id.name if employee and employee.job_id else ' '
record.signed_user_id = self.env.user
else:
record.job_name = False
record.signed_user_id = False
REPORT_ID = 'exp_transation_letters.report_letter_action_report'
pdf = self.env.ref(REPORT_ID)._render_qweb_pdf(self.ids)
# pdf result is a list
@ -138,9 +146,6 @@ class Letters(models.Model):
'mimetype': 'application/pdf'
})
# self.attachment_generated = True
employee = self.env['hr.employee'].search([('user_id', '=', attach_id.create_uid.id)], limit=1)
record.job_name = employee.job_id.name if employee and employee.job_id else ' '
record.signed_user_id = attach_id.create_uid
self.state = 'attached'
return self.env['cm.attachment.rule'].sudo().create({
'employee_id': self.unite.id,