diff --git a/support/README.rst b/support/README.rst new file mode 100644 index 0000000..5d8ebc6 --- /dev/null +++ b/support/README.rst @@ -0,0 +1,55 @@ +======= +Support +======= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:855fe761de693eead0e3c0b2089a90e99dc1deda377363bb8cc8daddb76f2668 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-Akretion%2Fsupport-lightgray.png?logo=github + :target: https://github.com/Akretion/support/tree/18.0/support + :alt: Akretion/support + +|badge1| |badge2| |badge3| + +Create Task from client Odoo from any menu + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Akretion + +Maintainers +----------- + +This module is part of the `Akretion/support `_ project on GitHub. + +You are welcome to contribute. diff --git a/support/__init__.py b/support/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/support/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/support/__manifest__.py b/support/__manifest__.py new file mode 100644 index 0000000..e4942e3 --- /dev/null +++ b/support/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2025 Akretion (http://www.akretion.com). +# @author Florian Mounier +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Support", + "summary": "Provide cross connect support integration", + "version": "18.0.1.0.0", + "license": "AGPL-3", + "author": "Akretion", + "website": "https://github.com/akretion/support", + "depends": [ + "cross_connect_client", + ], + "data": [ + "data/cross_connect_server.xml", + "data/ir_actions_server.xml", + ], +} diff --git a/support/data/cross_connect_server.xml b/support/data/cross_connect_server.xml new file mode 100644 index 0000000..e677924 --- /dev/null +++ b/support/data/cross_connect_server.xml @@ -0,0 +1,14 @@ + + + + + Support + your-server-url/api-support + Paste remote api key here + + + diff --git a/support/data/ir_actions_server.xml b/support/data/ir_actions_server.xml new file mode 100644 index 0000000..a75863a --- /dev/null +++ b/support/data/ir_actions_server.xml @@ -0,0 +1,15 @@ + + + + + Créer un ticket support + + + code + action = model.redirect_to_support() + + diff --git a/support/models/__init__.py b/support/models/__init__.py new file mode 100644 index 0000000..8fa8191 --- /dev/null +++ b/support/models/__init__.py @@ -0,0 +1,2 @@ +from . import ir_actions +from . import cross_connect_server diff --git a/support/models/cross_connect_server.py b/support/models/cross_connect_server.py new file mode 100644 index 0000000..cae7838 --- /dev/null +++ b/support/models/cross_connect_server.py @@ -0,0 +1,81 @@ +# Copyright 2025 Akretion (http://www.akretion.com). +# @author Florian Mounier +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import re +from urllib.parse import urlencode, urlparse + +from odoo import api, models + +AKRETION_EMAILS_RE = re.compile(r"^(.*@akretion\.com(\.br)?)$") + + +class CrossConnectServer(models.Model): + _inherit = "cross.connect.server" + + @api.model + def redirect_to_support(self): + """Redirect to the support page""" + # Any user with low rights may have the right to create tickets but can't + # read cross.connect.server. + self = self.sudo() + server = self.env.ref("support.support_server") + url = f"/cross_connect_server/{server.id}" + params = { + "origin_db": self.env.cr.dbname, + } + res_model = self.env.context.get("active_model") + res_id = self.env.context.get("active_id") + params["origin_url"] = ( + self.env["ir.config_parameter"].sudo().get_param("web.base.url") or "" + ) + if res_model and res_id: + record = self.env[res_model].browse(res_id) + params["origin_name"] = record.display_name + + url_params = { + "view_type": "form", + "model": res_model, + "id": res_id, + "active_id": res_id, + "cids": ",".join(str(x) for x in self.env.companies.ids), + } + + action = self.env.context.get("params", {}).get("action") + if not action: + action = self.env["ir.actions.act_window"].search( + [("res_model", "=", res_model), ("view_mode", "ilike", "form")], + limit=1, + ) + if action: + action = action.id + if action: + url_params["action"] = action + + params["origin_url"] += f"/web#{urlencode(url_params)}" + + redirect_params = { + "action": "project_customer_access.action_view_all_task", + "view_type": "form", + **{ + f"project.task_default_{field}": value + for field, value in params.items() + }, + } + + final_params = {"redirect_url": f"/web#{urlencode(redirect_params)}"} + url += "?" + urlencode(final_params) + + # Akretion users specific case + if self.env.user.email and AKRETION_EMAILS_RE.match(self.env.user.email): + redirect_params["action"] = "project.action_view_task" + server_url = urlparse(server.server_url) + server_url = server_url._replace( + path="/web", + fragment=urlencode(redirect_params), + ) + url = server_url.geturl() + return { + "type": "ir.actions.act_url", + "url": url, + "target": "new", + } diff --git a/support/models/ir_actions.py b/support/models/ir_actions.py new file mode 100644 index 0000000..d394b0b --- /dev/null +++ b/support/models/ir_actions.py @@ -0,0 +1,28 @@ +# Copyright 2025 Akretion (http://www.akretion.com). +# @author Florian Mounier +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class IrActions(models.Model): + _inherit = "ir.actions.actions" + + @api.model + def get_bindings(self, model_name): + """Add support action to every model""" + res = super().get_bindings(model_name) + support_server = ( + self.sudo().env.ref("support.support_server", raise_if_not_found=False) + or self.env["cross.connect.server"].sudo() + ) + support_groups = self.env.user.groups_id & support_server.group_ids + if support_groups: + action_id = "support.cross_connect_support" + if "action" in res: + if action_id not in [act.get("xml_id") for act in res["action"]]: + res["action"].append(self._for_xml_id(action_id)) + else: + res["action"] = [self._for_xml_id(action_id)] + + return res diff --git a/support/pyproject.toml b/support/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/support/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/support/readme/DESCRIPTION.md b/support/readme/DESCRIPTION.md new file mode 100644 index 0000000..0e7e522 --- /dev/null +++ b/support/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Create Task from client Odoo from any menu diff --git a/support/static/description/index.html b/support/static/description/index.html new file mode 100644 index 0000000..262e40c --- /dev/null +++ b/support/static/description/index.html @@ -0,0 +1,409 @@ + + + + + +Support + + + +
+

Support

+ + +

Beta License: AGPL-3 Akretion/support

+

Create Task from client Odoo from any menu

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Maintainers

+

This module is part of the Akretion/support project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/support/static/img/icon.png b/support/static/img/icon.png new file mode 100644 index 0000000..b2fb4ae Binary files /dev/null and b/support/static/img/icon.png differ