diff --git a/url_redirect_to_action/README.rst b/url_redirect_to_action/README.rst new file mode 100644 index 000000000..798494fb7 --- /dev/null +++ b/url_redirect_to_action/README.rst @@ -0,0 +1,86 @@ +====================== +Url Redirect to Action +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:738ebe02d90aae0492a06f0ceccdf669a72a0a39d68fea34f431c89fc03c3ce8 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-OCA%2Fserver--backend-lightgray.png?logo=github + :target: https://github.com/OCA/server-backend/tree/18.0/url_redirect_to_action + :alt: OCA/server-backend +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-backend-18-0/server-backend-18-0-url_redirect_to_action + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Translate url parameters to an odoo action. + +**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 + +Contributors +------------ + +- Akretion + + - David BEAL david.beal@akretion.com + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-bealdav| image:: https://github.com/bealdav.png?size=40px + :target: https://github.com/bealdav + :alt: bealdav + +Current `maintainer `__: + +|maintainer-bealdav| + +This module is part of the `OCA/server-backend `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/url_redirect_to_action/__init__.py b/url_redirect_to_action/__init__.py new file mode 100644 index 000000000..91c5580fe --- /dev/null +++ b/url_redirect_to_action/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/url_redirect_to_action/__manifest__.py b/url_redirect_to_action/__manifest__.py new file mode 100644 index 000000000..17462007f --- /dev/null +++ b/url_redirect_to_action/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright (C) 2025 - Today: Akretion +# @author: David BEAL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Url Redirect to Action", + "version": "18.0.1.0.0", + "author": "Akretion, " "Odoo Community Association (OCA)", + "summary": "Translate url parameters to an odoo action.", + "category": "Tools", + "website": "https://github.com/OCA/server-backend", + "license": "AGPL-3", + "depends": ["base"], + "maintainers": ["bealdav"], + "data": [], + "demo": [], +} diff --git a/url_redirect_to_action/controllers/__init__.py b/url_redirect_to_action/controllers/__init__.py new file mode 100644 index 000000000..12a7e529b --- /dev/null +++ b/url_redirect_to_action/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/url_redirect_to_action/controllers/main.py b/url_redirect_to_action/controllers/main.py new file mode 100644 index 000000000..19a3174b8 --- /dev/null +++ b/url_redirect_to_action/controllers/main.py @@ -0,0 +1,16 @@ +from odoo import http +from odoo.http import request + + +class UrlRedirectToAction(http.Controller): + @http.route("/web/redirect/", type="http", auth="user") + def redirect(self, action_name, **kwargs): + env = request.env + env["base"]._redirect_to_action_from_url(action_name, kwargs) + known_action = env.ref(action_name, raise_if_not_found=False) + if known_action: + path = known_action.path + if path: + return request.redirect(f"/odoo/{path}") + else: + return request.redirect(f"/odoo/action-{known_action.id}") diff --git a/url_redirect_to_action/models/__init__.py b/url_redirect_to_action/models/__init__.py new file mode 100644 index 000000000..0e4444933 --- /dev/null +++ b/url_redirect_to_action/models/__init__.py @@ -0,0 +1 @@ +from . import base diff --git a/url_redirect_to_action/models/base.py b/url_redirect_to_action/models/base.py new file mode 100644 index 000000000..972ce6259 --- /dev/null +++ b/url_redirect_to_action/models/base.py @@ -0,0 +1,13 @@ +from odoo import api, models + + +class Base(models.AbstractModel): + _inherit = "base" + + @api.model + def _redirect_to_action_from_url(self, action_name, values): + action = self.env.ref(action_name, raise_if_not_found=False) + if action: + action = action._get_action_dict() + # TODO no effect for now + return action diff --git a/url_redirect_to_action/pyproject.toml b/url_redirect_to_action/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/url_redirect_to_action/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/url_redirect_to_action/readme/CONTRIBUTORS.md b/url_redirect_to_action/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..7997db4f3 --- /dev/null +++ b/url_redirect_to_action/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Akretion + + - David BEAL diff --git a/url_redirect_to_action/readme/DESCRIPTION.md b/url_redirect_to_action/readme/DESCRIPTION.md new file mode 100644 index 000000000..3d76c75c6 --- /dev/null +++ b/url_redirect_to_action/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Translate url parameters to an odoo action. diff --git a/url_redirect_to_action/static/description/index.html b/url_redirect_to_action/static/description/index.html new file mode 100644 index 000000000..f3c1ca715 --- /dev/null +++ b/url_redirect_to_action/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +Url Redirect to Action + + + +
+

Url Redirect to Action

+ + +

Beta License: AGPL-3 OCA/server-backend Translate me on Weblate Try me on Runboat

+

Translate url parameters to an odoo action.

+

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
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

bealdav

+

This module is part of the OCA/server-backend project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ +