Skip to content

Commit

Permalink
[IMP] helpdesk_mgmt: Add settings to define required fields
Browse files Browse the repository at this point in the history
Added configuration to SET the Category and Team fields of the portal form as required.

TT45297
  • Loading branch information
victoralmau committed Oct 3, 2023
1 parent 89d1f19 commit 1685390
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 360 deletions.
7 changes: 7 additions & 0 deletions helpdesk_mgmt/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,20 @@ def create_new_ticket(self, **kw):
)
email = http.request.env.user.email
name = http.request.env.user.name
company = request.env.company

Check warning on line 52 in helpdesk_mgmt/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt/controllers/main.py#L52

Added line #L52 was not covered by tests
return http.request.render(
"helpdesk_mgmt.portal_create_ticket",
{
"categories": categories,
"teams": self._get_teams(),
"email": email,
"name": name,
"ticket_team_id_required": (
company.helpdesk_mgmt_portal_team_id_required
),
"ticket_category_id_required": (
company.helpdesk_mgmt_portal_category_id_required
),
},
)

Expand Down
411 changes: 61 additions & 350 deletions helpdesk_mgmt/i18n/es.po

Large diffs are not rendered by default.

30 changes: 23 additions & 7 deletions helpdesk_mgmt/i18n/helpdesk_mgmt.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-28 11:36+0000\n"
"PO-Revision-Date: 2023-09-28 11:36+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -774,9 +776,7 @@ msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,help:helpdesk_mgmt.field_helpdesk_ticket__message_has_error
#: model:ir.model.fields,help:helpdesk_mgmt.field_helpdesk_ticket__message_has_sms_error
#: model:ir.model.fields,help:helpdesk_mgmt.field_helpdesk_ticket_team__message_has_error
#: model:ir.model.fields,help:helpdesk_mgmt.field_helpdesk_ticket_team__message_has_sms_error
msgid "If checked, some messages have a delivery error."
msgstr ""

Expand Down Expand Up @@ -1151,14 +1151,30 @@ msgid "Reporting"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket__activity_user_id
msgid "Responsible User"
#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt.res_config_settings_view_form
msgid "Required Category"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_res_company__helpdesk_mgmt_portal_category_id_required
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_res_config_settings__helpdesk_mgmt_portal_category_id_required
msgid "Required Category field in Helpdesk portal"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket__message_has_sms_error
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket_team__message_has_sms_error
msgid "SMS Delivery error"
#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt.res_config_settings_view_form
msgid "Required Team"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_res_company__helpdesk_mgmt_portal_team_id_required
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_res_config_settings__helpdesk_mgmt_portal_team_id_required
msgid "Required Team field in Helpdesk portal"
msgstr ""

#. module: helpdesk_mgmt
#: model:ir.model.fields,field_description:helpdesk_mgmt.field_helpdesk_ticket__activity_user_id
msgid "Responsible User"
msgstr ""

#. module: helpdesk_mgmt
Expand Down
6 changes: 6 additions & 0 deletions helpdesk_mgmt/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ class Company(models.Model):
helpdesk_mgmt_portal_select_team = fields.Boolean(
string="Select team in Helpdesk portal"
)
helpdesk_mgmt_portal_team_id_required = fields.Boolean(
string="Required Team field in Helpdesk portal"
)
helpdesk_mgmt_portal_category_id_required = fields.Boolean(
string="Required Category field in Helpdesk portal"
)
15 changes: 14 additions & 1 deletion helpdesk_mgmt/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models
from odoo import api, fields, models


class ResConfigSettings(models.TransientModel):
Expand All @@ -10,3 +10,16 @@ class ResConfigSettings(models.TransientModel):
related="company_id.helpdesk_mgmt_portal_select_team",
readonly=False,
)
helpdesk_mgmt_portal_team_id_required = fields.Boolean(
related="company_id.helpdesk_mgmt_portal_team_id_required",
readonly=False,
)
helpdesk_mgmt_portal_category_id_required = fields.Boolean(
related="company_id.helpdesk_mgmt_portal_category_id_required",
readonly=False,
)

@api.onchange("helpdesk_mgmt_portal_select_team")
def _onchange_helpdesk_mgmt_portal_select_team(self):
for item in self.filtered(lambda x: not x.helpdesk_mgmt_portal_select_team):
item.helpdesk_mgmt_portal_team_id_required = False

Check warning on line 25 in helpdesk_mgmt/models/res_config_settings.py

View check run for this annotation

Codecov / codecov/patch

helpdesk_mgmt/models/res_config_settings.py#L25

Added line #L25 was not covered by tests
4 changes: 2 additions & 2 deletions helpdesk_mgmt/views/helpdesk_ticket_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@
class="form-control"
id="team"
name="team"
required="True"
t-att-required="ticket_team_id_required"
>
<option value="" />
<t t-foreach="teams" t-as="team">
Expand All @@ -427,7 +427,7 @@
class="form-control"
id="category"
name="category"
required="True"
t-att-required="ticket_category_id_required"
>
<option value="" />
<t t-foreach="categories" t-as="cat">
Expand Down
29 changes: 29 additions & 0 deletions helpdesk_mgmt/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,35 @@
<div class="text-muted">Show teams form</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field
name="helpdesk_mgmt_portal_team_id_required"
attrs="{'readonly' : [('helpdesk_mgmt_portal_select_team', '=', False)]}"
/>
</div>
<div class="o_setting_right_pane">
<label
for="helpdesk_mgmt_portal_team_id_required"
string="Required Team"
/>
</div>
</div>
</div>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field
name="helpdesk_mgmt_portal_category_id_required"
/>
</div>
<div class="o_setting_right_pane">
<label
for="helpdesk_mgmt_portal_category_id_required"
string="Required Category"
/>
</div>
</div>
</div>
</div>
</xpath>
Expand Down

0 comments on commit 1685390

Please sign in to comment.