Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1468 Zobrazení

I built a simple module addon in 17.0 to extend the web_editor to allow for a 10-star rating in addition to the 3 and 5 star ratings. It's essentially only one file, plus the manifest. (

__manifest__.py (updated for 18.0):

{
'name': 'Web Editor 10 Star Rating',
'version': '18.0.1.0.0',
'summary': 'Add a 10-star rating option to the WYSIWYG editor Powerbox',
'sequence': 20,
'description': 'This module extends the WYSIWYG editor Powerbox to include a 10-star rating option.',
'category': 'Tools',
'depends': ['web_editor'],
'assets': {
'web_editor.assets_wysiwyg': [
'web_editor_extensions/static/src/js/wysiwyg.js',
],
},
'data': [],
'qweb': [],
'installable': True,
'application': False,
'auto_install': False,
}

static/src/js/wysiwyg.js:

/** odoo-module **/
import { Wysiwyg } from '@web_editor/js/wysiwyg/wysiwyg';
import { patch } from '@web/core/utils/patch';
import { _t } from '@web/core/l10n/translation';
import {parseHTML} from '@web_editor/js/editor/odoo-editor/src/utils/utils'

patch(Wysiwyg.prototype, {
_getPowerboxOptions() {
const options = super._getPowerboxOptions();
const wysiwyg = this

options.commands.push({
category: _t('Widgets'),
name: _t('10 Stars'),
priority: 5,
description: _t('Insert a rating over 10 stars'),
fontawesome: 'fa-star',
callback: function () {
let html = '\u200B<span contenteditable="false" class="o_stars o_ten_stars">';
html += Array(10).fill().map(() => '<i class="fa fa-star-o"></i>').join('');
html += '</span>\u200B';
wysiwyg.odooEditor.execCommand('insert', parseHTML(window.document, html));
},
});
return options;
},
});

This works perfectly in Odoo 17.0, I just activate the module and I can create the 10-star ratings in any web editor through the powerbox.

But when I install this in Odoo 18.0, nothing happens, it doesn't even look like the javascript file is getting loaded. I put console logs in to test and nothing. Did Odoo 18.0 change something about how to load these javascript modules? I can't seem to find any documentation on this. If anyone can test on their end and potentially identify the issue, I'd appreciate it! Feel free to use the code for your own uses if you'd like a 10-star rating!

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
dub 24
1128
1
lis 23
3163
0
srp 18
6647
2
čvc 25
1282
1
kvě 25
797