[IMP] website: remove the get_modules_info route

For the "+New" button, a `get_modules_info` route was added because the
information cannot be built-in the page by a server-side QWeb template
anymore.

This commit removes this route and replaces it by a call to the default
`search_read`.

task-2687506

closes odoo/odoo#102791

X-original-commit: 7f83e398b68d7c7544753e2b8bb1b334fb5f7036
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Benoit Socias
2022-10-09 22:03:55 +02:00
parent 76d03f50c9
commit 90ddaf871d
2 changed files with 17 additions and 14 deletions
-10
View File
@@ -353,16 +353,6 @@ class Website(Home):
]
}
@http.route('/website/get_modules_info', type='json', auth="user")
def get_modules_info(self, xml_ids):
def get_module_info(xml_id):
module_info = request.env.ref(xml_id)
return {'id': module_info.id, 'name': module_info.shortdesc}
modules_info = {}
for xml_id in xml_ids:
modules_info[xml_id] = get_module_info(xml_id)
return modules_info
@http.route('/website/snippet/filters', type='json', auth='public', website=True)
def get_dynamic_filter(self, filter_id, template_key, limit=None, search_domain=None, with_sample=False):
dynamic_filter = request.env['website.snippet.filter'].sudo().search(
@@ -72,18 +72,21 @@ export class NewContentModal extends Component {
this.state = useState({
newContentElements: [
{
moduleName: 'website_blog',
moduleXmlId: 'base.module_website_blog',
status: MODULE_STATUS.NOT_INSTALLED,
icon: xml`<i class="fa fa-rss"/>`,
title: this.env._t('Blog Post'),
},
{
moduleName: 'website_event',
moduleXmlId: 'base.module_website_event',
status: MODULE_STATUS.NOT_INSTALLED,
icon: xml`<i class="fa fa-ticket"/>`,
title: this.env._t('Event'),
},
{
moduleName: 'website_forum',
moduleXmlId: 'base.module_website_forum',
status: MODULE_STATUS.NOT_INSTALLED,
icon: xml`<i class="fa fa-comment"/>`,
@@ -91,24 +94,28 @@ export class NewContentModal extends Component {
title: this.env._t('Forum'),
},
{
moduleName: 'website_hr_recruitment',
moduleXmlId: 'base.module_website_hr_recruitment',
status: MODULE_STATUS.NOT_INSTALLED,
icon: xml`<i class="fa fa-briefcase"/>`,
title: this.env._t('Job Position'),
},
{
moduleName: 'website_sale',
moduleXmlId: 'base.module_website_sale',
status: MODULE_STATUS.NOT_INSTALLED,
icon: xml`<i class="fa fa-shopping-cart"/>`,
title: this.env._t('Product'),
},
{
moduleName: 'website_slides',
moduleXmlId: 'base.module_website_slides',
status: MODULE_STATUS.NOT_INSTALLED,
icon: xml`<i class="fa module_icon" style="background-image: url('/website/static/src/img/apps_thumbs/website_slide.svg');background-repeat: no-repeat; background-position: center;"/>`,
title: this.env._t('Course'),
},
{
moduleName: 'website_livechat',
moduleXmlId: 'base.module_website_livechat',
status: MODULE_STATUS.NOT_INSTALLED,
icon: xml`<i class="fa fa-comments"/>`,
@@ -131,10 +138,16 @@ export class NewContentModal extends Component {
async onWillStart() {
this.isDesigner = await this.user.hasGroup('website.group_website_designer');
this.canInstall = await this.user.isAdmin;
const xmlIds = this.state.newContentElements.filter(({status}) => status === MODULE_STATUS.NOT_INSTALLED).map(({moduleXmlId}) => moduleXmlId);
if (this.canInstall) {
this.modulesInfo = await this.rpc('/website/get_modules_info', {xml_ids: xmlIds});
const moduleNames = this.state.newContentElements.filter(({status}) => status === MODULE_STATUS.NOT_INSTALLED).map(({moduleName}) => moduleName);
this.modulesInfo = {};
for (const record of await this.orm.searchRead(
"ir.module.module",
[['name', 'in', moduleNames]],
["id", "name", "shortdesc"],
)) {
this.modulesInfo[record.name] = {id: record.id, name: record.shortdesc};
}
}
}
@@ -169,7 +182,7 @@ export class NewContentModal extends Component {
return element.createNewContent();
}
const {id, name} = this.modulesInfo[element.moduleXmlId];
const {id, name} = this.modulesInfo[element.moduleName];
const dialogProps = {
title: element.title,
installationText: _.str.sprintf(this.newContentText.installNeeded, name),