简体   繁体   English

如何在 Odoo v13 中自定义 Web 编辑器顶部菜单?

[英]How to customize Web-editor Top-menu in Odoo v13?

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.我创建了一个新模块(“webeditor_custom”)来自定义 Odoo v13 Web 编辑器顶部菜单以在现有菜单项中添加自定义字体大小。

在此处输入图像描述

The files in my module "webeditor_custom" are:我的模块“webeditor_custom”中的文件是:

  1. templates/assets.xml file:模板/资产.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, i have my summernote_cust.js file:在 /static/src/js/ 目录中,我有我的 summernote_cust.js 文件:
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:我的清单.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"],
}

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" “错误:服务 web_editor.summernote_cust 已定义”

Thank you if you have a way to deal with it (summernote on odoo v13) or a workaround如果您有办法处理它(odoo v13 上的summernote)或解决方法,谢谢

Try to add your script to the assets_wysiwyg bundle, so it will be added after all the summernote scripts尝试将您的脚本添加到assets_wysiwyg包中,这样它将在所有Summernote脚本之后添加

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM