Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

How to pass parameters to cleditor ?

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
viewparametershtmlcleditor
1 Svar
7787 Visninger
Avatar
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
Avatar
Kassér
Avatar
Thierry Godin
Forfatter Bedste svar

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
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
How to pass parameters to cleditor + dl link
view parameters html cleditor
Avatar
Avatar
8
jul. 15
7008
[15 Community] E-Mail Marketing - No HTML view for all messages
view marketing html E-mail
Avatar
0
jan. 23
2114
address with ampersand in qweb Løst
xml view qweb html
Avatar
Avatar
1
okt. 22
9088
Creating a dynamic url and execute it
form view html metabase
Avatar
0
maj 22
3907
translate knowledge articles tabs
knowledge xml view html body
Avatar
1
jun. 23
2603
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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