PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 24, 2022

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

 August 24, 2022     javascript, module, odoo, odoo-13, summernote     No comments   

Issue

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 !


Solution

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>


Answered By - Kenly
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing