fix2 Department Manager

This commit is contained in:
Mazen Abdo 2024-11-06 10:28:32 +02:00
parent b4907dcd84
commit 1d2d145d9b
5 changed files with 8 additions and 7 deletions

View File

@ -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) 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() from_hr_depart = fields.Boolean()
name = fields.Char(string="Name") name = fields.Char(string="Name")
department_id= fields.Many2one('hr.department') depart_id= fields.Many2one('hr.department')
@ -120,7 +120,7 @@ class RequestVehicleDelegation(models.Model):
def direct_manager(self): def direct_manager(self):
for rec in self: for rec in self:
rec.state = 'direct_manager' rec.state = 'direct_manager'
rec.send_notification_to_fleet_tool_group()
def send_notification_to_fleet_tool_group(self): def send_notification_to_fleet_tool_group(self):
message_template = 'عزيز {user_name} لديك طلب تفويض بحاجة الى موافقة' message_template = 'عزيز {user_name} لديك طلب تفويض بحاجة الى موافقة'
@ -135,7 +135,7 @@ class RequestVehicleDelegation(models.Model):
'message_type': 'notification', 'message_type': 'notification',
'subtype_id': self.env.ref('mail.mt_comment').id, 'subtype_id': self.env.ref('mail.mt_comment').id,
'body': message_body, 'body': message_body,
'subject': 'طلب تفويض جديد', 'subject': 'New authorization request',
'partner_ids': [(4, user.partner_id.id)], 'partner_ids': [(4, user.partner_id.id)],
'model': 'request.vehicle.authorization', 'model': 'request.vehicle.authorization',
'res_id': self.id, 'res_id': self.id,
@ -160,7 +160,7 @@ class RequestVehicleDelegation(models.Model):
'last_project_id': self.last_project_id.id if self.last_project_id else False, 'last_project_id': self.last_project_id.id if self.last_project_id else False,
'last_branch_id': self.last_branch_id.id, 'last_branch_id': self.last_branch_id.id,
'custody_id': self.custody_id.id if self.custody_id else False, 'custody_id': self.custody_id.id if self.custody_id else False,
'department_id': self.department_id.id if self.department_id else False, 'depart_id': self.depart_id.id if self.depart_id else False,
'request_vehicle_authorization': self.id 'request_vehicle_authorization': self.id
} }
_logger.info("Attempting to create vehicle delegation with values: %s", vehicle_vals) _logger.info("Attempting to create vehicle delegation with values: %s", vehicle_vals)
@ -169,6 +169,7 @@ class RequestVehicleDelegation(models.Model):
_logger.info("Created vehicle delegation: %s", vehicle) _logger.info("Created vehicle delegation: %s", vehicle)
self.state = "fleet_tool" self.state = "fleet_tool"
self.send_notification_to_fleet_tool_group()
return vehicle return vehicle

View File

@ -52,7 +52,7 @@ class VehicleDelegation(models.Model):
last_department_id = fields.Many2one(related='vehicle_id.department_id', string="Last Department",help='The last Department the vehicle was authorized for') last_department_id = fields.Many2one(related='vehicle_id.department_id', string="Last Department",help='The last Department the vehicle was authorized for')
last_project_id = fields.Many2one('project.project', string='Last Project', compute="get_last_project", store=True) last_project_id = fields.Many2one('project.project', string='Last Project', compute="get_last_project", store=True)
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') 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')
depart_id= fields.Many2one('hr.department')
@api.depends("vehicle_id") @api.depends("vehicle_id")
def get_first_odometer(self): def get_first_odometer(self):
for rec in self : for rec in self :

View File

@ -39,7 +39,7 @@
<field name="license_number" readonly="1" force_save="1"/> <field name="license_number" readonly="1" force_save="1"/>
<field name="license_end" readonly="1" force_save="1"/> <field name="license_end" readonly="1" force_save="1"/>
<!-- <field name="custody_id" invisible="1"/>--> <!-- <field name="custody_id" invisible="1"/>-->
<field name="department_id" attrs="{'readonly': [('state', '!=', 'draft')]}"/> <field name="depart_id" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
</group> </group>
<div class="oe_title"> <div class="oe_title">
<label for="vehicle_id" class="oe_edit_only"/> <label for="vehicle_id" class="oe_edit_only"/>
@ -84,7 +84,7 @@
<tree> <tree>
<field name="employee_id"/> <field name="employee_id"/>
<field name="vehicle_id"/> <field name="vehicle_id"/>
<field name="department_id"/> <field name="depart_id"/>
</tree> </tree>
</field> </field>