From da8c652e084350a2d6a69b2d05bc5afecf309732 Mon Sep 17 00:00:00 2001 From: mohammed-alkhazrji Date: Tue, 22 Jul 2025 22:05:44 +0300 Subject: [PATCH] change the actit --- .../models/odex25_helpdesk_ticket.py | 125 ------------------ 1 file changed, 125 deletions(-) diff --git a/odex25_helpdesk/odex25_helpdesk/models/odex25_helpdesk_ticket.py b/odex25_helpdesk/odex25_helpdesk/models/odex25_helpdesk_ticket.py index 63fecc503..bd70af51a 100644 --- a/odex25_helpdesk/odex25_helpdesk/models/odex25_helpdesk_ticket.py +++ b/odex25_helpdesk/odex25_helpdesk/models/odex25_helpdesk_ticket.py @@ -1093,128 +1093,3 @@ class odex25_helpdeskTicket(models.Model): self.stage_id = draft_stage.id else: raise ValidationError(_("No draft stage found.")) - - def write(self, vals): - if vals.get('stage_id'): - new_stage = self.env['odex25_helpdesk.stage'].browse(vals['stage_id']) - if new_stage.is_close: - vals['is_submitted'] = True - return super().write(vals) - - - - - - - # def _resolve_next_stage(self): - # """Return the best next stage according to the following order: - # 1) If `next_stage` is set and unique -> use it. - # 2) If there are multiple -> take the first one that intersects with the team's stages. - # 3) If not set -> use the first stage with a higher sequence than the current one within the team. - # """ - # - # self.ensure_one() - # if self.stage_id.employee_created: - # if self.partner_id != self.env.user.partner_id: - # raise ValidationError( - # _("You cannot proceed to the next stage because you are not the employee linked to this ticket.")) - # if self.stage_id.manager_approved: - # employee = self.env['hr.employee'].search([('user_partner_id', '=', self.partner_id.id)], limit=1) - # - # if not employee: - # raise ValidationError(_("Employee not found based on partner_id.")) - # - # if employee.parent_id.user_id != self.env.user: - # raise ValidationError(_("Only the employee's manager can approve this stage.")) - # if self.stage_id.needs_approval: - # if self.stage_id.is_group_approver: - # group_ext_id = self.env['ir.model.data'].search([ - # ('model', '=', 'res.groups'), - # ('res_id', '=', self.stage_id.group_id.id) - # ], limit=1).complete_name - # - # if not self.env.user.has_group(group_ext_id): - # raise ValidationError( - # _("Only members of the '%s' group can approve this stage.") % self.stage_id.group_id.name) - # - # else: - # if self.stage_id.user_id != self.env.user: - # raise ValidationError(_("Only '%s' can approve this stage.") % self.stage_id.user_id.name) - # if self.stage_id.next_stage: - # return self.stage_id.next_stage - # - # stages = self.team_id.stage_ids.sorted(key=lambda s: s.sequence) - # for st in stages: - # if st.sequence > self.stage_id.sequence: - # return st - # return False - # # -------------------------------------------------- - # # Action Buttons - # # -------------------------------------------------- - # def action_confirm(self): - # for ticket in self: - # next_stage = ticket._resolve_next_stage() - # - # if not next_stage: - # raise ValidationError(_("No next stage is configured for this ticket!")) - # ticket.stage_id = next_stage - # - # def action_rejection(self): - # self.ensure_one() - # rejection_stage = self.team_id.stage_ids.filtered(lambda s: s.final_rejection_stage) - # if rejection_stage: - # self.stage_id = rejection_stage[0] - # else: - # raise ValidationError(_("No final rejection stage is defined within the team's stages.")) - # - # # -------------------------------------------------- - # # Override write to mark is_submitted when closing - # # -------------------------------------------------- - # def write(self, vals): - # if vals.get('stage_id'): - # new_stage = self.env['odex25_helpdesk.stage'].browse(vals['stage_id']) - # if new_stage.is_close: - # vals['is_submitted'] = True - # return super().write(vals) - # - # def _resolve_previous_stage(self): - # self.ensure_one() - # if self.stage_id.employee_created: - # if self.partner_id != self.env.user.partner_id: - # raise ValidationError( - # _("You cannot proceed to the Previous stage because you are not the employee linked to this ticket.")) - # if self.stage_id.manager_approved: - # employee = self.env['hr.employee'].search([('user_partner_id', '=', self.partner_id.id)], limit=1) - # - # if not employee: - # raise ValidationError(_("Employee not found based on partner_id.")) - # - # if employee.parent_id.user_id != self.env.user: - # raise ValidationError(_("Only the employee's manager can Previous this stage.")) - # if self.stage_id.needs_approval: - # if self.stage_id.is_group_approver: - # group_ext_id = self.env['ir.model.data'].search([ - # ('model', '=', 'res.groups'), - # ('res_id', '=', self.stage_id.group_id.id) - # ], limit=1).complete_name - # - # if not self.env.user.has_group(group_ext_id): - # raise ValidationError( - # _("Only members of the '%s' group can approve this stage.") % self.stage_id.group_id.name) - # else: - # if self.stage_id.user_id != self.env.user: - # raise ValidationError(_("Only '%s' can approve this stage.") % self.stage_id.user_id.name) - # if self.stage_id.previous_stage: - # return self.stage_id.previous_stage - # stages = self.team_id.stage_ids.sorted(key=lambda s: s.sequence, reverse=True) - # for st in stages: - # if st.sequence < self.stage_id.sequence: - # return st - # return False - # - # def action_back(self): - # for ticket in self: - # prev_stage = ticket._resolve_previous_stage() - # if not prev_stage: - # raise ValidationError(_("No previous stage is configured for this ticket!")) - # ticket.stage_id = prev_stage \ No newline at end of file