Merge pull request #1722 from expsa/zen_fix_notification_id
Send the notification to appear as a real notification in Odoo
This commit is contained in:
commit
53ef65ab82
Binary file not shown.
Binary file not shown.
|
|
@ -122,8 +122,9 @@ class RequestVehicleDelegation(models.Model):
|
||||||
rec.state = 'direct_manager'
|
rec.state = 'direct_manager'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def send_notification_to_fleet_tool_group(self):
|
def send_notification_to_fleet_tool_group(self):
|
||||||
message_template = 'عزيز {user_name} لديك طلب تفويض بحاجة الى موافقة'
|
message_template = 'Dear {user_name}, you have an authorization request awaiting approval'
|
||||||
group = self.env.ref('odex_fleet.group_fleet_tool')
|
group = self.env.ref('odex_fleet.group_fleet_tool')
|
||||||
users = group.users
|
users = group.users
|
||||||
|
|
||||||
|
|
@ -131,6 +132,7 @@ class RequestVehicleDelegation(models.Model):
|
||||||
if user.partner_id:
|
if user.partner_id:
|
||||||
message_body = message_template.format(user_name=user.name)
|
message_body = message_template.format(user_name=user.name)
|
||||||
|
|
||||||
|
# Send the notification to appear as a real notification in Odoo
|
||||||
self.env['mail.message'].create({
|
self.env['mail.message'].create({
|
||||||
'message_type': 'notification',
|
'message_type': 'notification',
|
||||||
'subtype_id': self.env.ref('mail.mt_comment').id,
|
'subtype_id': self.env.ref('mail.mt_comment').id,
|
||||||
|
|
@ -140,6 +142,10 @@ class RequestVehicleDelegation(models.Model):
|
||||||
'model': 'request.vehicle.authorization',
|
'model': 'request.vehicle.authorization',
|
||||||
'res_id': self.id,
|
'res_id': self.id,
|
||||||
'author_id': self.env.user.partner_id.id,
|
'author_id': self.env.user.partner_id.id,
|
||||||
|
'notification_ids': [(0, 0, {
|
||||||
|
'res_partner_id': user.partner_id.id,
|
||||||
|
'notification_type': 'inbox'
|
||||||
|
})]
|
||||||
})
|
})
|
||||||
def fleet_tool(self):
|
def fleet_tool(self):
|
||||||
|
|
||||||
|
|
@ -167,9 +173,9 @@ class RequestVehicleDelegation(models.Model):
|
||||||
|
|
||||||
vehicle = self.env['vehicle.delegation'].create(vehicle_vals)
|
vehicle = self.env['vehicle.delegation'].create(vehicle_vals)
|
||||||
_logger.info("Created vehicle delegation: %s", vehicle)
|
_logger.info("Created vehicle delegation: %s", vehicle)
|
||||||
|
|
||||||
self.state = "fleet_tool"
|
|
||||||
self.send_notification_to_fleet_tool_group()
|
self.send_notification_to_fleet_tool_group()
|
||||||
|
self.state = "fleet_tool"
|
||||||
|
|
||||||
return vehicle
|
return vehicle
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue