如何在Odoo V13中自定义Web编辑Top-Menu?

发布于 2025-02-07 16:48:22 字数 1748 浏览 1 评论 0原文

我创建了一个新的模块(“ webeditor_custom”),以自定义ODOO V13 Web Editor顶部菜单,以在现有菜单项中添加自定义字体大小。

我的模块中的文件” webeditor_custom”为:

  1. 模板/assets.xml文件:
<?xml version="1.0" encoding="utf-8" ?>

<odoo>

<template id="summernote_cust" name="My summernote assets" inherit_id="web_editor.summernote">

<xpath expr="//script[last()]" position="after">

<script type="text/javascript" src="/webeditor_custom/static/src/js/summernote_cust.js"></script>

</xpath>

</template>

</odoo>
  1. in/static/src/js/directory,我有我的summernote_cust.js file:
odoo.define('web_editor.summernote_cust', function (require) {

'use strict';

var core = require('web.core');

var editor = require('web_editor.summernote');

require('summernote/summernote'); // wait that summernote is loaded

var _t = core._t;

var options = $.summernote.options;

options.fontSizes = [_t('Default'), 8, 9, 10, 11, 12, 13, 14, 16, 18, 21, 24, 28, 32, 36, 42, 49, 56, 63];

return $.summernote;

});
  1. 我的 sustest .py文件:
{
    "name": "Web editor custom",
    "summary": "Add font-sizes to the top-menu of the web editor",
    "version": "13.0.2.0.1",
    "installable": True,
    "depends": ["web_editor"],
    "data": ["templates/assets.xml"],
}

安装我的模块后,我在主页的第一个负载上显示此错误(弹出):

“ error:service web_editor.summernote_cust已经定义了” >

感谢您是否有办法处理它(ODOO V13上的Summernote)或解决方法!

I have created a new module ("webeditor_custom") to customize Odoo v13 Web editor Top menu to add custom font-sizes in the existing menu items.

enter image description here

The files in my module "webeditor_custom" are :

  1. templates/assets.xml file :
<?xml version="1.0" encoding="utf-8" ?>

<odoo>

<template id="summernote_cust" name="My summernote assets" inherit_id="web_editor.summernote">

<xpath expr="//script[last()]" position="after">

<script type="text/javascript" src="/webeditor_custom/static/src/js/summernote_cust.js"></script>

</xpath>

</template>

</odoo>
  1. In /static/src/js/ directory, i have my summernote_cust.js file :
odoo.define('web_editor.summernote_cust', function (require) {

'use strict';

var core = require('web.core');

var editor = require('web_editor.summernote');

require('summernote/summernote'); // wait that summernote is loaded

var _t = core._t;

var options = $.summernote.options;

options.fontSizes = [_t('Default'), 8, 9, 10, 11, 12, 13, 14, 16, 18, 21, 24, 28, 32, 36, 42, 49, 56, 63];

return $.summernote;

});
  1. my manifest.py file:
{
    "name": "Web editor custom",
    "summary": "Add font-sizes to the top-menu of the web editor",
    "version": "13.0.2.0.1",
    "installable": True,
    "depends": ["web_editor"],
    "data": ["templates/assets.xml"],
}

After installing my module, i get this error (popup) displayed on the first load of my homepage:

"Error: Service web_editor.summernote_cust already defined"

Thank you if you have a way to deal with it (summernote on odoo v13) or a workaround !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

镜花水月 2025-02-14 16:48:22

尝试将您的脚本添加到Assets_wysiwyg捆绑包中,因此将在所有 summernote 脚本

示例:

<template id="summernote_cust" name="My summernote assets" inherit_id="web_editor.assets_wysiwyg">
    <xpath expr="//script[last()]" position="after">
        <script type="text/javascript" src="/webeditor_custom/static/src/js/summernote_cust.js"></script>
    </xpath>
</template>

Try to add your script to the assets_wysiwyg bundle, so it will be added after all the summernote scripts

Example:

<template id="summernote_cust" name="My summernote assets" inherit_id="web_editor.assets_wysiwyg">
    <xpath expr="//script[last()]" position="after">
        <script type="text/javascript" src="/webeditor_custom/static/src/js/summernote_cust.js"></script>
    </xpath>
</template>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文