commit
33a2f3cd3c
|
|
@ -11,6 +11,7 @@ class ForwardTransactionWizard(models.TransientModel):
|
|||
name = ''
|
||||
to_id = self.employee.id
|
||||
unit_id = self.employee.parent_id.id
|
||||
|
||||
if self.internal_transaction_id:
|
||||
transaction = self.internal_transaction_id
|
||||
name = 'internal_transaction_id'
|
||||
|
|
@ -20,37 +21,45 @@ class ForwardTransactionWizard(models.TransientModel):
|
|||
elif self.outgoing_transaction_id:
|
||||
transaction = self.outgoing_transaction_id
|
||||
name = 'outgoing_transaction_id'
|
||||
|
||||
|
||||
forward_user_id = self.employee.user_id.id
|
||||
if self.forward_type != 'employee':
|
||||
forward_user_id = self.internal_unit.secretary_id.user_id.id
|
||||
to_id = self.internal_unit.secretary_id.id
|
||||
unit_id = self.internal_unit.id
|
||||
|
||||
|
||||
transaction.forward_user_id = forward_user_id
|
||||
|
||||
|
||||
leave_employee = transaction.get_employee_leave(to_id, unit_id, date.today())
|
||||
if leave_employee:
|
||||
forward_user_id = self.env['cm.entity'].search([('id', '=', leave_employee)]).user_id.id
|
||||
to_id = leave_employee
|
||||
transaction.forward_user_id = forward_user_id
|
||||
|
||||
|
||||
transaction.last_forwarded_user = self.env.uid
|
||||
|
||||
|
||||
if self.is_secret:
|
||||
transaction.secret_reason = self.secret_reason
|
||||
transaction.secret_forward_user = self.env['cm.entity'].search([('user_id', '=', forward_user_id)], limit=1)
|
||||
|
||||
|
||||
employee = transaction.current_employee()
|
||||
from_id = self.env['cm.entity'].search([('user_id', '=', self.env.uid)], limit=1)
|
||||
|
||||
|
||||
transaction.is_forward = True
|
||||
|
||||
# Handle attachment rule
|
||||
|
||||
# Handle attachment rule (Binary field)
|
||||
if self.forward_attachment_id:
|
||||
attachment = self.env['ir.attachment'].browse(self.forward_attachment_id.ids)
|
||||
transaction.file_save = [(6, 0, attachment.ids)] # Ensure the attachment IDs are set correctly
|
||||
|
||||
# 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,
|
||||
})
|
||||
transaction.file_save = [(4, attachment.id)] # Link the created attachment
|
||||
|
||||
# Create trace record
|
||||
transaction.trace_ids.create({
|
||||
'action': 'forward',
|
||||
|
|
@ -61,10 +70,10 @@ class ForwardTransactionWizard(models.TransientModel):
|
|||
'cc_ids': [(6, 0, self.cc_ids.ids)],
|
||||
name: transaction.id
|
||||
})
|
||||
|
||||
|
||||
if self.internal_transaction_id or self.incoming_transaction_id:
|
||||
transaction.action_send_forward()
|
||||
|
||||
|
||||
# Notification
|
||||
target = self.forward_type
|
||||
target_name = target == 'employee' and self.employee.name or self.internal_unit.name
|
||||
|
|
@ -76,7 +85,7 @@ class ForwardTransactionWizard(models.TransientModel):
|
|||
_(u'Action Taken'), self.procedure_id.name,
|
||||
u'<a href="%s" >رابط المعاملة</a> ' % (transaction.get_url())
|
||||
)
|
||||
|
||||
|
||||
# Add mail notification
|
||||
partner_ids = []
|
||||
if self.forward_type == 'unit':
|
||||
|
|
@ -88,9 +97,10 @@ class ForwardTransactionWizard(models.TransientModel):
|
|||
partner_ids.append(partner.secretary_id.user_id.partner_id.id)
|
||||
elif partner.type == 'employee':
|
||||
partner_ids.append(partner.user_id.partner_id.id)
|
||||
|
||||
|
||||
transaction.action_send_notification(subj, msg, partner_ids)
|
||||
|
||||
|
||||
if self.incoming_transaction_id:
|
||||
if transaction.state == 'draft':
|
||||
transaction.state = 'send'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue