Skip to content
This repository has been archived by the owner on Dec 17, 2019. It is now read-only.

Accept changing ticket category without changing sub category #80

Open
wants to merge 1 commit into
base: 11.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion website_support/models/website_support_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ def _default_approval_id(self):
sla_alert_ids = fields.Many2many('website.support.sla.alert', string="SLA Alerts",
help="Keep record of SLA alerts sent so we do not resend them")

#add constrains on sub_category_id
@api.constrains('sub_category_id')
def _check_subcategory(self):
# if the sub_category_id not a child of the selected category then raise an error.
if any(ticket.sub_category_id and ticket.sub_category_id.parent_category_id != ticket.category for ticket in self):
raise ValidationError(_('Error: Your selected sub category not a child of the parent category.'))
return True

@api.multi
@api.depends('subject', 'ticket_number')
def name_get(self):
Expand Down Expand Up @@ -799,4 +807,4 @@ def send_reply(self):
else:
#Change the ticket state to staff replied
staff_replied = self.env['ir.model.data'].get_object('website_support','website_ticket_state_staff_replied')
self.ticket_id.state = staff_replied.id
self.ticket_id.state = staff_replied.id