commit
044e3e230e
|
|
@ -20,31 +20,38 @@ 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
|
||||
|
||||
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.id)], limit=1)
|
||||
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
|
||||
if self.forward_attachment_id:
|
||||
transaction.attachment_rule_ids.create({
|
||||
'file_save': self.forward_attachment_id,
|
||||
'name': transaction.id,
|
||||
'description': self.att_description,
|
||||
'attachment_filename': self.filename,
|
||||
})
|
||||
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
|
||||
|
||||
# Create trace record
|
||||
transaction.trace_ids.create({
|
||||
'action': 'forward',
|
||||
'to_id': to_id,
|
||||
|
|
@ -54,19 +61,23 @@ 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()
|
||||
'''for notification partner in cc or forward user'''
|
||||
|
||||
# Notification
|
||||
target = self.forward_type
|
||||
target_name = target == 'employee' and self.employee.name or self.internal_unit.name
|
||||
subj = _('Message Has been forwarded !')
|
||||
msg = _(u'{} ← {}').format(
|
||||
employee and employee.name or '#', target_name)
|
||||
msg = u'{}<br /><b>{}</b> {}.<br />{}'.format(msg,
|
||||
_(u'Action Taken'), self.procedure_id.name,
|
||||
u'<a href="%s" >رابط المعاملة</a> ' % (
|
||||
transaction.get_url()))
|
||||
# add mail notification
|
||||
msg = u'{}<br /><b>{}</b> {}.<br />{}'.format(
|
||||
msg,
|
||||
_(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':
|
||||
partner_ids.append(self.internal_unit.secretary_id.user_id.partner_id.id)
|
||||
|
|
@ -77,7 +88,9 @@ 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