From e3a68986f65e42823e2456733b48204d63c4d50a Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Mon, 26 Aug 2024 06:10:25 +0200 Subject: [PATCH 1/2] base_url: improve views --- base_url/models/abstract_url.py | 24 ++++++++++++++++++++---- base_url/models/url_url.py | 2 +- base_url/views/url_view.xml | 27 ++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/base_url/models/abstract_url.py b/base_url/models/abstract_url.py index a553f2328c..7a679d1510 100644 --- a/base_url/models/abstract_url.py +++ b/base_url/models/abstract_url.py @@ -131,12 +131,15 @@ def _compute_redirect_url_url_ids(self): self.flush() for record in self: record.redirect_url_url_ids = record.env["url.url"].search( - [ - ("model_id", "=", get_model_ref(record)), - ("redirect", "=", True), - ] + record._redirect_url_domain() ) + def _redirect_url_domain(self): + return [ + ("model_id", "=", get_model_ref(self)), + ("redirect", "=", True), + ] + @api.depends("url_key") def _compute_url_url_ids(self): self.flush() @@ -228,3 +231,16 @@ def unlink(self): urls.unlink() self.flush() return super(AbstractUrl, self).unlink() + + def action_view_redirect_url(self): + self.ensure_one() + action = self.env["ir.actions.actions"]._for_xml_id( + "base_url.base_url_action_view" + ) + action["name"] = action["display_name"] = _("Redirects") + action["domain"] = self._redirect_url_domain() + action["context"] = { + "default_model_id": get_model_ref(self), + "default_redirect": True, + } + return action diff --git a/base_url/models/url_url.py b/base_url/models/url_url.py index 407843cf85..7cee2d3038 100644 --- a/base_url/models/url_url.py +++ b/base_url/models/url_url.py @@ -21,7 +21,7 @@ class UrlUrl(models.Model): selection="_selection_target_model", help="The id of content linked to the url.", readonly=True, - string="Model", + string="Record", required=True, index=True, ) diff --git a/base_url/views/url_view.xml b/base_url/views/url_view.xml index 3767cceed8..cc4d8c1fba 100644 --- a/base_url/views/url_view.xml +++ b/base_url/views/url_view.xml @@ -21,11 +21,28 @@ url.url - - - - - + + + + + + + + + + url.url + + + + + + + + From 9bbf87c981094fcecaff75a932ebded2341d2293 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Mon, 26 Aug 2024 06:11:08 +0200 Subject: [PATCH 2/2] shopinvader: allow to manage URLs --- shopinvader/views/shopinvader_category_view.xml | 6 ++++++ shopinvader/views/shopinvader_product_view.xml | 7 +++++++ shopinvader/views/shopinvader_variant_view.xml | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/shopinvader/views/shopinvader_category_view.xml b/shopinvader/views/shopinvader_category_view.xml index d725123132..f50fedc309 100644 --- a/shopinvader/views/shopinvader_category_view.xml +++ b/shopinvader/views/shopinvader_category_view.xml @@ -63,6 +63,12 @@ +