diff --git a/odex25_fleet/odex_fleet/models/__pycache__/request_vehicle_authorization.cpython-38.pyc b/odex25_fleet/odex_fleet/models/__pycache__/request_vehicle_authorization.cpython-38.pyc
index e4360c7fd..acaecd09c 100644
Binary files a/odex25_fleet/odex_fleet/models/__pycache__/request_vehicle_authorization.cpython-38.pyc and b/odex25_fleet/odex_fleet/models/__pycache__/request_vehicle_authorization.cpython-38.pyc differ
diff --git a/odex25_fleet/odex_fleet/models/request_vehicle_authorization.py b/odex25_fleet/odex_fleet/models/request_vehicle_authorization.py
index b0a953e09..e19697af5 100644
--- a/odex25_fleet/odex_fleet/models/request_vehicle_authorization.py
+++ b/odex25_fleet/odex_fleet/models/request_vehicle_authorization.py
@@ -49,7 +49,7 @@ class RequestVehicleDelegation(models.Model):
last_branch_id = fields.Many2one('hr.department', string="Last Branch", compute="get_last_branch", store=True,help='The last Branch the vehicle was authorized for',tracking=True)
from_hr_depart = fields.Boolean()
name = fields.Char(string="Name")
- departments_id= fields.Many2one('hr.department')
+ department_id= fields.Many2one('hr.department')
@@ -117,12 +117,30 @@ class RequestVehicleDelegation(models.Model):
'context': {'default_delegation_id': self.id},
}
-
-
def direct_manager(self):
for rec in self:
rec.state = 'direct_manager'
+ rec.send_notification_to_fleet_tool_group()
+ def send_notification_to_fleet_tool_group(self):
+ message_template = 'عزيز {user_name} لديك طلب تفويض بحاجة الى موافقة'
+ group = self.env.ref('odex_fleet.group_fleet_tool')
+ users = group.users
+
+ for user in users:
+ if user.partner_id:
+ message_body = message_template.format(user_name=user.name)
+
+ self.env['mail.message'].create({
+ 'message_type': 'notification',
+ 'subtype_id': self.env.ref('mail.mt_comment').id,
+ 'body': message_body,
+ 'subject': 'طلب تفويض جديد',
+ 'partner_ids': [(4, user.partner_id.id)],
+ 'model': 'request.vehicle.authorization',
+ 'res_id': self.id,
+ 'author_id': self.env.user.partner_id.id,
+ })
def fleet_tool(self):
vehicle_vals = {
@@ -142,7 +160,7 @@ class RequestVehicleDelegation(models.Model):
'last_project_id': self.last_project_id.id if self.last_project_id else False,
'last_branch_id': self.last_branch_id.id,
'custody_id': self.custody_id.id if self.custody_id else False,
- 'departments_id': self.departments_id.id if self.departments_id else False,
+ 'department_id': self.department_id.id if self.department_id else False,
'request_vehicle_authorization': self.id
}
_logger.info("Attempting to create vehicle delegation with values: %s", vehicle_vals)
diff --git a/odex25_fleet/odex_fleet/security/security_view.xml b/odex25_fleet/odex_fleet/security/security_view.xml
index d9ca756fd..73b1b709a 100644
--- a/odex25_fleet/odex_fleet/security/security_view.xml
+++ b/odex25_fleet/odex_fleet/security/security_view.xml
@@ -111,13 +111,15 @@
+