[NEW] helpdesk_portal_ticket_priority_form: create add-on

This commit is contained in:
Stéphan Sainléger
2024-10-03 23:54:51 +02:00
parent 826d242023
commit cd47dab34a
9 changed files with 212 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
*.*~
*pyc

View File

@@ -0,0 +1,37 @@
====================================
helpdesk_portal_ticket_priority_form
====================================
Add fieds in ticket creation portal form for priority.
# Installation
Use Odoo normal module installation procedure to install
`helpdesk_portal_ticket_enriched_description_form`.
# Known issues / Roadmap
None yet.
# Bug Tracker
Bugs are tracked on `our issues website <https://github.com/elabore-coop/helpdesk-tools/issues>`\_. In case of
trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback.
# Credits
## Contributors
- Stéphan Sainléger
## Funders
The development of this module has been financially supported by:
- Elabore (https://elabore.coop)
## Maintainer
This module is maintained by Elabore.

View File

@@ -0,0 +1 @@
from . import controllers

View File

@@ -0,0 +1,35 @@
# Copyright 2024 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "helpdesk_portal_ticket_priority_form",
"version": "14.0.1.1.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Stéphan Sainléger",
"license": "AGPL-3",
"category": "Tools",
"summary": "Add fieds in ticket creation portal form for priority.",
# any module necessary for this one to work correctly
"depends": [
"base",
"helpdesk_mgmt",
],
"qweb": [],
"external_dependencies": {
"python": [],
},
# always loaded
"data": [
"views/helpdesk_ticket_templates.xml",
],
# only loaded in demonstration mode
"demo": [],
"js": [],
"css": [],
"installable": True,
# Install this module automatically if all dependency have been previously
# and independently installed. Used for synergetic or glue modules.
"auto_install": False,
"application": False,
}

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import main

View File

@@ -0,0 +1,26 @@
import odoo.http as http
from odoo.addons.helpdesk_mgmt.controllers.main import HelpdeskTicketController
class HelpdeskTicketControllerPriority(HelpdeskTicketController):
def _get_ticket_priorities(self):
priorities = []
for id, name in (
http.request.env["helpdesk.ticket"]._fields["priority"].selection
):
priorities.append({"id": id, "name": name})
return priorities
@http.route("/new/ticket", type="http", auth="user", website=True)
def create_new_ticket(self, **kw):
res = super(HelpdeskTicketControllerPriority, self).create_new_ticket(**kw)
res.qcontext["priorities"] = self._get_ticket_priorities()
return res
def _prepare_submit_ticket_vals(self, **kw):
res = super()._prepare_submit_ticket_vals(**kw)
request_type = http.request.env["helpdesk.request.type"].browse(
int(kw.get("request_type"))
)
res.update({"request_type_id": request_type.id})
return res

View File

@@ -0,0 +1,26 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * helpdesk_portal_ticket_priority_form
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-03 21:48+0000\n"
"PO-Revision-Date: 2024-10-03 21:48+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: helpdesk_portal_ticket_priority_form
#: model_terms:ir.ui.view,arch_db:helpdesk_portal_ticket_priority_form.helptdesk_create_ticket_priority
msgid "<option value=\"\">Choose a priority...</option>"
msgstr "<option value=\"\">Choisir une priorité...</option>"
#. module: helpdesk_portal_ticket_priority_form
#: model_terms:ir.ui.view,arch_db:helpdesk_portal_ticket_priority_form.helptdesk_create_ticket_priority
msgid "Priority"
msgstr "Priorité"

View File

@@ -0,0 +1,26 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * helpdesk_portal_ticket_priority_form
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-03 21:43+0000\n"
"PO-Revision-Date: 2024-10-03 21:43+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: helpdesk_portal_ticket_priority_form
#: model_terms:ir.ui.view,arch_db:helpdesk_portal_ticket_priority_form.helptdesk_create_ticket_priority
msgid "<option value=\"\">Choose a priority...</option>"
msgstr ""
#. module: helpdesk_portal_ticket_priority_form
#: model_terms:ir.ui.view,arch_db:helpdesk_portal_ticket_priority_form.helptdesk_create_ticket_priority
msgid "Priority"
msgstr ""

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="portal_my_tickets_priority_widget_template" name="Priority Widget Template">
<span t-attf-class="o_priority_star fa fa-star#{'' if ticket.priority >= '1' else '-o'}" />
<span t-attf-class="o_priority_star fa fa-star#{'' if ticket.priority >= '2' else '-o'}" />
<span t-attf-class="o_priority_star fa fa-star#{'' if ticket.priority == '3' else '-o'}" />
</template>
<!-- Ticket create form -->
<template id="helptdesk_create_ticket_priority" name="Create Ticket: Priority"
inherit_id="helpdesk_mgmt.portal_create_ticket" priority="40">
<xpath expr="//form/div[2]" position="after">
<div class="form-group">
<label
class="col-md-3 col-sm-4 control-label"
for="priority"
>Priority
</label>
<div class="col-md-7 col-sm-8">
<select name="priority" t-attf-class="form-control" required="True">
<option value="">Choose a priority...</option>
<t t-foreach="priorities or []" t-as="priority">
<option t-att-value="priority['id']">
<t t-esc="priority['name']" />
</option>
</t>
</select>
</div>
</div>
</xpath>
</template>
<!-- Tickets portal list -->
<template id="portal_ticket_list_priority" name="Ticket Portal List Template : Priority"
inherit_id="helpdesk_mgmt.portal_ticket_list">
<xpath expr="//thead/tr/th[3]" position="after">
<th t-if="groupby == 'none'">Priority</th>
</xpath>
<xpath expr="//tbody/t/tr/td[3]" position="after">
<td>
<t
t-call="helpdesk_portal_ticket_priority_form.portal_my_tickets_priority_widget_template" />
</td>
</xpath>
</template>
<!-- Ticket portal page -->
<template id="portal_helpdesk_ticket_page_priority" name="Ticket Portal Template : Priority"
inherit_id="helpdesk_mgmt.portal_helpdesk_ticket_page">
<xpath expr="//h5/div/span" position="before">
<t
t-call="helpdesk_portal_ticket_priority_form.portal_my_tickets_priority_widget_template" />
</xpath>
</template>
</odoo>