简体   繁体   中英

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.

在此处输入图像描述

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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