[IMP] test_website: add a test of multi websites settings

In the website settings, one of the fields allows you to switch settings
from one website to another. Unfortunately, as soon as the user did this
the record was considered to have changed (dirty) and therefore required
a save when it wasn't necessary. The previous commit prevents the header
settings (like the website switcher) from dirtying the record. This was
really necessary because as soon as a user had several websites, it was
impossible for him to access certain settings on all these websites
(except the first one). As soon as the setting performed an action, a
save was required (because the record was dirty) and the user was
redirected to the settings again.
Steps to reproduce the issue before the previous commit:

Install website
Have multiple websites
Go to Settings > Website Settings
Change the website
=> The user is notified that the record has changed and needs to be
saved, which is not true. So far it's annoying but not critical, but if
the user continues:

Activate the "Extra step during checkout" option
Click on "Configure Form"
=> The Save/Discard dialog appears because the record is dirty.

Click on "Save"
=> The user is redirected to the settings page again and cannot access
the form configuration of the second website. (it is the same issue for
most of actions).

The previous commit fixes the issue and this commit adds a test to
ensure that the users are able to change settings of multiple websites.

task-3265100

closes odoo/odoo#126387

X-original-commit: bed37396839891da04126a71b3d6a6e5e56672b0
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
This commit is contained in:
Guillaume (gdi)
2023-06-26 22:15:17 +02:00
parent ad131c6187
commit be90d8abae
6 changed files with 94 additions and 0 deletions
+1
View File
@@ -1,2 +1,3 @@
from . import model
from . import res_config_settings
from . import website
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
def action_website_test_setting(self):
return self.env['website'].get_client_action('/')
@@ -0,0 +1,57 @@
/** @odoo-module */
import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_service/tour_utils";
const websiteName = "Website Test Settings";
registry.category("web_tour.tours").add("website_settings_m2o_dirty", {
test: true,
url: "/web",
steps: [
stepUtils.showAppsMenuItem(),
{
content: "open settings",
trigger: ".o_app[data-menu-xmlid='base.menu_administration']",
},
{
content: "open website settings",
trigger: ".settings_tab .tab[data-key='website']",
},
{
content: "check that the 'Shared Customers Accounts' setting is checked",
trigger: "input[id^='shared_user_account']:checked",
isCheck: true,
},
{
content: "open website switcher",
trigger: "input[id^='website_id']",
},
{
content: `select ${websiteName} in the website switcher`,
trigger: `li:has(.dropdown-item:contains('${websiteName}'))`,
},
{
content: `check that the settings of ${websiteName} are loaded (Shared Customers Accounts)`,
trigger: "input[id^='shared_user_account']:not(:checked)",
isCheck: true,
},
{
content: "click on the fake website setting after checking the edited website",
trigger: "button[name='action_website_test_setting']",
},
{
content: "check that we are on '/'",
trigger: "iframe body div#wrap",
run: function () {
if (window.location.pathname !== "/") {
// If this fails, it's probably because the change of website
// in the settings dirty the record and so there is a dialog
// save/discard displayed. This test ensure that does not happen
// because it makes actions unreachable in multi website.
console.error("We should be on '/' the settings didn't work");
}
},
},
],
});
+1
View File
@@ -15,4 +15,5 @@ from . import test_qweb
from . import test_redirect
from . import test_reset_views
from . import test_session
from . import test_settings
from . import test_views_during_module_operation
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import odoo
import odoo.tests
@odoo.tests.tagged('-at_install', 'post_install')
class TestWebsiteSettings(odoo.tests.HttpCase):
def test_01_multi_website_settings(self):
self.env['website'].create({'name': "Website Test Settings", 'specific_user_account': True})
self.start_tour("/web", 'website_settings_m2o_dirty', login="admin")
+13
View File
@@ -18,4 +18,17 @@
</t>
</field>
</record>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.test.website</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="website.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//setting[@id='plausbile_setting']" position="after">
<div class="col-12 col-lg-6 o_setting_box" id="website_test_setting">
<button type="object" name="action_website_test_setting" string="Website test setting" class="btn-link" icon="fa-arrow-right"/>
</div>
</xpath>
</field>
</record>
</odoo>