[FIX] website: fix deleting a page from the page manager
Steps to reproduce the bug:
- Install the "Surveys" application.
- Go to the "Website" application.
- Go in the page manager ("Site" > "Pages").
- Select a page (typically "Home").
- Try to delete it.
- Error of type "'survey.survey' object has no attributes 'name'".
The error comes from the fact that records do not necessarily have the
attribute called "name". To fix this error, this commit uses
"display_name" that is defined in all models.
task-3082345
opw-3100483
opw-3111671
X-original-commit: d5aa5d7ebf9cd17a6df054252a1313ec8b85e83e
Part-of: odoo/odoo#109329
This commit is contained in:
@@ -844,7 +844,7 @@ class Website(models.Model):
|
||||
dependencies.setdefault(model_name, [])
|
||||
dependencies[model_name] += [{
|
||||
'field_name': Model.fields_get()[column]['string'],
|
||||
'record_name': rec.name,
|
||||
'record_name': rec.display_name,
|
||||
'link': 'website_url' in rec and rec.website_url or f'/web#id={rec.id}&view_type=form&model={model}',
|
||||
'model_name': model_name,
|
||||
} for rec in dependency_records]
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import wTourUtils from 'website.tour_utils';
|
||||
|
||||
const deleteSelectedPage = [
|
||||
{
|
||||
content: "Click on Action",
|
||||
trigger: '.o_cp_action_menus button',
|
||||
},
|
||||
{
|
||||
content: "Click on Delete",
|
||||
trigger: '.o-dropdown--menu span:contains("Delete")',
|
||||
},
|
||||
{
|
||||
content: "Click on I am sure about this",
|
||||
trigger: 'main.modal-body input[type="checkbox"]',
|
||||
// The loading of the dependencies can take a while and
|
||||
// sometimes reach the default 10s timeout
|
||||
timeout: 20000,
|
||||
},
|
||||
{
|
||||
content: "Click on OK",
|
||||
trigger: '.modal-content footer button.btn-primary',
|
||||
}
|
||||
];
|
||||
const homePage = 'tr:contains("Home"):has(td[name="website_id"]:empty)';
|
||||
|
||||
wTourUtils.registerWebsitePreviewTour('website_page_manager', {
|
||||
test: true,
|
||||
url: '/',
|
||||
}, [
|
||||
{
|
||||
content: "Click on Site",
|
||||
trigger: 'button.dropdown-toggle[title="Site"]',
|
||||
},
|
||||
{
|
||||
content: "Click on Pages",
|
||||
trigger: 'a.dropdown-item[data-menu-xmlid="website.menu_website_pages_list"]',
|
||||
},
|
||||
{
|
||||
content: "Click on Home Page",
|
||||
trigger: `.o_list_renderer ${homePage} td.o_list_record_selector input[type="checkbox"]`,
|
||||
},
|
||||
...deleteSelectedPage,
|
||||
{
|
||||
content: "Check that the page has been removed",
|
||||
trigger: `.o_list_renderer:not(:has(${homePage}))`,
|
||||
run: () => null,
|
||||
},
|
||||
{
|
||||
content: "Click on All Pages",
|
||||
trigger: '.o_list_renderer thead input[type="checkbox"]',
|
||||
},
|
||||
...deleteSelectedPage,
|
||||
{
|
||||
content: "Check that all pages have been removed",
|
||||
trigger: '.o_list_renderer tbody:not(:has([data-id]))',
|
||||
run: () => null,
|
||||
},
|
||||
]);
|
||||
@@ -17,6 +17,7 @@ from . import test_http_endpoint
|
||||
from . import test_lang_url
|
||||
from . import test_menu
|
||||
from . import test_page
|
||||
from . import test_page_manager
|
||||
from . import test_performance
|
||||
from . import test_qweb
|
||||
from . import test_res_users
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import odoo.tests
|
||||
|
||||
@odoo.tests.common.tagged('post_install', '-at_install')
|
||||
class TestWebsitePageManager(odoo.tests.HttpCase):
|
||||
|
||||
def test_01_page_manager(self):
|
||||
self.start_tour(self.env['website'].get_client_action_url('/'), 'website_page_manager', login="admin")
|
||||
Reference in New Issue
Block a user