Skip to content
Draft
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
86 changes: 86 additions & 0 deletions url_redirect_to_action/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/server-backend/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/OCA/server-backend/issues/new?body=module:%20url_redirect_to_action%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

Contributors
------------

- Akretion

- David BEAL [email protected]

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-bealdav|

This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/18.0/url_redirect_to_action>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions url_redirect_to_action/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
17 changes: 17 additions & 0 deletions url_redirect_to_action/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [],
}
1 change: 1 addition & 0 deletions url_redirect_to_action/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
16 changes: 16 additions & 0 deletions url_redirect_to_action/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import http
from odoo.http import request


class UrlRedirectToAction(http.Controller):
@http.route("/web/redirect/<string:action_name>", 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)

Check warning on line 10 in url_redirect_to_action/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

url_redirect_to_action/controllers/main.py#L8-L10

Added lines #L8 - L10 were not covered by tests
if known_action:
path = known_action.path

Check warning on line 12 in url_redirect_to_action/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

url_redirect_to_action/controllers/main.py#L12

Added line #L12 was not covered by tests
if path:
return request.redirect(f"/odoo/{path}")

Check warning on line 14 in url_redirect_to_action/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

url_redirect_to_action/controllers/main.py#L14

Added line #L14 was not covered by tests
else:
return request.redirect(f"/odoo/action-{known_action.id}")

Check warning on line 16 in url_redirect_to_action/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

url_redirect_to_action/controllers/main.py#L16

Added line #L16 was not covered by tests
1 change: 1 addition & 0 deletions url_redirect_to_action/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import base
13 changes: 13 additions & 0 deletions url_redirect_to_action/models/base.py
Original file line number Diff line number Diff line change
@@ -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)

Check warning on line 9 in url_redirect_to_action/models/base.py

View check run for this annotation

Codecov / codecov/patch

url_redirect_to_action/models/base.py#L9

Added line #L9 was not covered by tests
if action:
action = action._get_action_dict()

Check warning on line 11 in url_redirect_to_action/models/base.py

View check run for this annotation

Codecov / codecov/patch

url_redirect_to_action/models/base.py#L11

Added line #L11 was not covered by tests
# TODO no effect for now
return action

Check warning on line 13 in url_redirect_to_action/models/base.py

View check run for this annotation

Codecov / codecov/patch

url_redirect_to_action/models/base.py#L13

Added line #L13 was not covered by tests
3 changes: 3 additions & 0 deletions url_redirect_to_action/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions url_redirect_to_action/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Akretion

- David BEAL <[email protected]>
1 change: 1 addition & 0 deletions url_redirect_to_action/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Translate url parameters to an odoo action.
Loading