Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

How to pass parameters to cleditor ?

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
viewparametershtmlcleditor
1 Atsakyti
7858 Rodiniai
Portretas
Thierry Godin

Hi folk,

I'm trying to pass parameters to cleditor to change controls, styles and others parameters dynamically

Maybe from view with options or attrs ??

For now, I edited view_form.js , but I'd prefer avoid changes of official addons in case of updates.

Any suggestion are welcome

Thanks.

0
Portretas
Atmesti
Portretas
Thierry Godin
Autorius Best Answer

Hi folk,

I found a workaround to pass parameters to cleditor :

This is in view_forms.js of web module, replace initialize_content() as below (around line 2699) :

initialize_content: function() {
    var self = this;
    if (! this.get("effective_readonly")) {
        self._updating_editor = false;
        this.$textarea = this.$el.find('textarea');

        var e_width = ((this.node.attrs || {}).editor_width || '100%');

        var e_height = ((this.node.attrs || {}).editor_height || 250);

        var e_controls = ((this.node.attrs || {}).editor_controls || 
                        "bold italic underline strikethrough " +
                        "| removeformat | bullets numbering | outdent " +
                        "indent | link unlink | source"
                        );

        var e_colors = ((this.node.attrs || {}).editor_colors || 
                        "FFF FCC FC9 FF9 FFC 9F9 9FF CFF CCF FCF " +
                        "CCC F66 F96 FF6 FF3 6F9 3FF 6FF 99F F9F " +
                        "BBB F00 F90 FC6 FF0 3F3 6CC 3CF 66C C6C " +
                        "999 C00 F60 FC3 FC0 3C0 0CC 36F 63F C3C " +
                        "666 900 C60 C93 990 090 399 33F 60C 939 " +
                        "333 600 930 963 660 060 366 009 339 636 " +
                        "000 300 630 633 330 030 033 006 309 303"
                        );

        var e_fonts =((this.node.attrs || {}).editor_fonts ||
                        "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," +
                        "Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana"
                        );

        var e_sizes = ((this.node.attrs || {}).editor_sizes || "1,2,3,4,5,6,7");

        var e_docType = ((this.node.attrs || {}).editor_docType || 
                        '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
                        );

        var e_styles = [["Paragraph", "<p>"], ["Header 1", "<h1>"], ["Header 2", "<h2>"],
                        ["Header 3", "<h3>"],  ["Header 4","<h4>"],  ["Header 5","<h5>"],
                        ["Header 6","<h6>"]];

        var e_useCSS = true ;

                    if((this.node.attrs || {}).editor_useCSS){
                        console.log('editor_useCSS : ' + (this.node.attrs || {}).editor_useCSS);
                        if((this.node.attrs || {}).editor_useCSS == "true" ){
                            e_useCSS = true;
                       }
                    } 

        var e_docCSSFile = ((this.node.attrs || {}).editor_docCSSFile|| "");

        var e_bodyStyle = ((this.node.attrs || {}).editor_bodyStyle || 
                        "margin:4px; color:#4c4c4c; font-size:13px; " +
                        "font-family:'Lucida Grande',Helvetica,Verdana, " + 
                        "Arial,sans-serif; cursor:text"
                        );

        this.$textarea.cleditor({
                width:        e_width,
                height:       e_height,
                controls:     e_controls,
                colors:       e_colors,    
                fonts:        e_fonts,
                sizes:        e_sizes,
                docType:      e_docType,
                styles:       e_styles,
                useCSS:       e_useCSS,
                docCSSFile:   e_docCSSFile, 
                bodyStyle:    e_bodyStyle,
        });

        this.$cleditor = this.$textarea.cleditor()[0];
        this.$cleditor.change(function() {
            if (! self._updating_editor) {
                self.$cleditor.updateTextArea();
                self.internal_set_value(self.$textarea.val());
            }
        });
        if (this.field.translate) {
            var $img = $('<img class="oe_field_translate oe_input_icon" src="/web/static/src/img/icons/terp-translate.png" width="16" height="16" border="0"/>')
                .click(this.on_translate);
            this.$cleditor.$toolbar.append($img);
        }
    }
},

Now you can pass parameters in a view to change cleditor properties :

  • editor_width : str (400px or %)
  • editor_height : str (400px or %)
  • editor_controls : array
  • editor_colors : str (hex colors , with space separator)
  • editor_fonts : str (font-names with comma separator)
  • editor_sizes : str (font-sizes with comma separator)
  • editor_doctype : str (doctype)
  • # not managed to deal with useCSS .... so i set it to True
  • editor_useCSS : true/false
  • editor_docCSSFile : str (path to css file)
  • editor_bodyStyle : str (CSS style)

Here is an example how to use it in a view (form) :

<field name="content" 
                           placeholder="e.g. Once upon a time..." 
                           widget="html" 
                           class="oe_edit_only" 
                           options='{"safe": True}'
                           editor_width="100%%"
                           editor_height="500"
                           editor_controls="bold italic underline strikethrough subscript superscript | font size style | color highlight removeformat | bullets numbering | outdent indent | alignleft center alignright justify | undo redo | rule image link unlink | cut copy paste pastetext | print source"
                           />

I had no time, but the best way would be to override Web module (in case you update openERP files)

hope this helps.

Best regards

0
Portretas
Atmesti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registracija
Related Posts Replies Rodiniai Veikla
How to pass parameters to cleditor + dl link
view parameters html cleditor
Portretas
Portretas
8
liep. 15
7071
[15 Community] E-Mail Marketing - No HTML view for all messages
view marketing html E-mail
Portretas
0
saus. 23
2157
address with ampersand in qweb Solved
xml view qweb html
Portretas
Portretas
1
spal. 22
9166
Creating a dynamic url and execute it
form view html metabase
Portretas
0
geg. 22
3956
translate knowledge articles tabs
knowledge xml view html body
Portretas
1
birž. 23
2657
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now