Skip to content
Open
Show file tree
Hide file tree
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
55 changes: 55 additions & 0 deletions support/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/Akretion/support/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 <https://github.com/Akretion/support/issues/new?body=module:%20support%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Akretion

Maintainers
-----------

This module is part of the `Akretion/support <https://github.com/Akretion/support/tree/18.0/support>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions support/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions support/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Akretion (http://www.akretion.com).
# @author Florian Mounier <florian.mounier@akretion.com>
# 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",
],
}
14 changes: 14 additions & 0 deletions support/data/cross_connect_server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2025 Akretion (http://www.akretion.com).
@author Florian Mounier <florian.mounier@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo noupdate="1">
<record id="support_server" model="cross.connect.server">
<field name="name">Support</field>
<field name="server_url">your-server-url/api-support</field>
<field name="api_key">Paste remote api key here</field>
<field name="web_icon_data" type="base64" file="support/static/img/icon.png" />
</record>
</odoo>
15 changes: 15 additions & 0 deletions support/data/ir_actions_server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2025 Akretion (http://www.akretion.com).
@author Florian Mounier <florian.mounier@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="cross_connect_support" model="ir.actions.server">
<field name="name">Créer un ticket support</field>
<field name="model_id" ref="cross_connect_client.model_cross_connect_server" />
<field name="groups_id" eval="[(4, ref('base.group_user'))]" />
<field name="state">code</field>
<field name="code">action = model.redirect_to_support()</field>
</record>
</odoo>
2 changes: 2 additions & 0 deletions support/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import ir_actions
from . import cross_connect_server
81 changes: 81 additions & 0 deletions support/models/cross_connect_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2025 Akretion (http://www.akretion.com).
# @author Florian Mounier <florian.mounier@akretion.com>
# 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",
}
28 changes: 28 additions & 0 deletions support/models/ir_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2025 Akretion (http://www.akretion.com).
# @author Florian Mounier <florian.mounier@akretion.com>
# 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
3 changes: 3 additions & 0 deletions support/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions support/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Create Task from client Odoo from any menu
Loading
Loading