From c7b80a93607d77b7b65773a3ef7bd3868622330b Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 24 Jan 2023 16:28:49 +0000 Subject: [PATCH] [FIX] website, *: restore publish and edit-in-backend as a non-designer *: website_sale During the big "website-in-backend" refactoring, [1] and [2] were made to add the "edit-in-backend" and publish buttons in the systray. At the same time, the information about if the main object of the iframe is available to "edit-in-backend" / is published was added on the loaded iframe's html element (as was already the information about what the main object is). The problem is that [1] + [2] were merged around the same time as [3] which decided to put the existing data addition on the html element... in a t-if. [1] and [2] ended up adding the new information only if the user is a designer, while it is actually needed as restricted editor users. As a result: the publish and "edit-in-backend" buttons did not appear anymore for restricted editor users. At the same time, [3] seems wrong on its own, as it moved some information in the conditional block although we wanted that information to be available even for visitors (especially, the main object which is for example used by the product snippet*). This is fixed by this commit too. * Steps to reproduce: - As a restricted editor, go to /shop in the backend iframe - Click on a category at the top - Edit - Add a "Products" snippet in the category-related area - Click on it and choose "Current" as the value for the category => Crash. That crash actually also occurs as a visitor on page load if such a snippet was saved by an admin first (but the crash in that case is silent). Note that the "seo-object" info is not needed by public users but was restored as a public data as it was the case in 15.0. It might make sense to some custo. However, the "oe-company-name" info, which was public in 15.0, is kept shown for designers only as it seems to be dead code in 16.0 (will be removed later on in master). Unfortunately, no stable fix can really be made to solve this issue: this commit had to modify the existing `website.layout` XML. So to solve this issue in existing databases, you either have to patch the view accordingly or update the website app. That should be ok, considering that the only real problem is that some options cannot be used as a restricted editor user. [1]: https://github.com/odoo/odoo/commit/f260e3c1441b380d0c9f5294d7cadcaad9c90662 [2]: https://github.com/odoo/odoo/commit/028efcbffe1cbaa00fe6a262151c75fda922008d [3]: https://github.com/odoo/odoo/commit/b0a2a41d78292cb8b9e53788d40c6dc5915a466d task-3129034 X-original-commit: bfb6d7820c35f3eba3bb760810866350092a16d9 Part-of: odoo/odoo#111289 --- addons/website/views/website_templates.xml | 14 +++-- ...sale_category_page_and_products_snippet.js | 59 +++++++++++++++++++ .../website_sale_restricted_editor_ui.js | 43 ++++++++++++++ .../website_sale/tests/test_website_editor.py | 27 +++++++++ 4 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 addons/website_sale/static/tests/tours/website_sale_category_page_and_products_snippet.js create mode 100644 addons/website_sale/static/tests/tours/website_sale_restricted_editor_ui.js diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 8889c16fb64..3b730487d2b 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -34,23 +34,25 @@