Update forward_trasaction.py

This commit is contained in:
zainab2097 2024-08-22 13:57:34 +03:00 committed by GitHub
parent 74f469799e
commit d39f772bf3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 6 deletions

View File

@ -51,14 +51,27 @@ class ForwardTransactionWizard(models.TransientModel):
if self.forward_attachment_id:
# Since it's a binary field, you would typically store the file somewhere or handle it according to your business logic.
# For example, you might want to store it in another model or create an attachment record.
# attachment = self.env['ir.attachment'].create({
# 'name': 'Forward Attachment',
# 'type': 'binary',
# 'datas': self.forward_attachment_id,
# 'res_model': transaction._name,
# 'res_id': transaction.id,
# })
attachment = self.env['ir.attachment'].create({
'name': 'Forward Attachment',
'type': 'binary',
'datas': self.forward_attachment_id,
'res_model': transaction._name,
'res_id': transaction.id,
'name': self.filename,
'datas': self.attachment_id,
'type': 'binary',
'res_model': 'cm.attachment.rule', # ضع هنا اسم النموذج الذي تقوم بحفظ المرفق له
'res_id': transaction.id, # المعرف المرتبط بالسجل الأساسي الذي تريد ربط المرفق به
})
transaction.attachment_rule_ids.create({
'file_save': [(4, attachment.id)], # ربط المرفق الذي تم إنشاؤه
# 'name': transaction.id,
'description': self.att_description,
'attachment_filename': self.filename,
})
transaction.file_save = [(4, attachment.id)] # Link the created attachment
# transaction.file_save = [(4, attachment.id)] # Link the created attachment
# Create trace record
transaction.trace_ids.create({