跳至內容
選單
此問題已被標幟
1485 瀏覽次數

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!

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
4月 24
1135
1
11月 23
3165
0
8月 18
6656
2
7月 25
1284
1
5月 25
798