This new functionality is based on 2 separate modules:
- web_display: This module provides a new widget to display HTML tags in the forms.
You need to add in your view’s field widget=”text_WYSIWYG” to see the result as HTML instead of text.
- web_html_wysiwyg: This module provides a WYSIWYG editor (based on CKeditor) that can be switched on any time in any OpenERP forms.
You need to add the following code in the views for which you want to turn the classic textareas into powerful WYSIWYG editors.
<a onclick=”javascript:toggle_ckeditor();” class=”wysiwyg_button wysiwyg_button_off oe_button”>WYSIWYG on</a>
Using both modules in combination in your views allows you to enable or disable the WYSIWYG editors anytime.
The first application where this feature could be used is in the wiki or the email modules in order to enhance the end-user experience.
You can grab the code at our launchpad address: https://code.launchpad.net/~openerp-community/openobject-addons/elico-6.1
and at http://apps.openerp.com
Enjoy!
Really cool feature. Thannks for contribute.
Awesome! thanks for this.
I’m having some problems tho using it in a wizard. It doesnt seem to initialise. If I refresh the page, the function is called but the div it gets displayed in is hidden.
Is there a better place to ask this question?
the version I downloaded didnt work correctly, but changing the js to:
openerp.web.form.widgets.add(‘text_WYSIWYG’, ‘openerp.web_display_html.FieldWYSIWYGReadonly’); //instead of ‘openerp.web.form.FieldText’
which worked – hope it helps someone.
Hello
I have a special case (in version 6.1), in which the text won’t be stored in the DB.
- I open an invoice
- I open an invoice line of this invoice
- I switch the WYSIWYG-Editor on
- I change the text (note)
- I save the invoice line
- I save the invoice
The changed text was not stored. If I try this with keeping the WYSIWYG-Editor off, it works.
I think the invoice don’t know, that the invoice line has changed (because the save button in the invoice form won’t be red after changing the text in the invoice line).
Can you help me?
thx
@Fred : Yeah we fixed this issue by modifying the.js, so you can download the new version in our launchpad. Otherwise you just need to switch the WYSIWYG off before clicking on save & close (or save & new).
@Timothy : It works fine for several persons, so which version of openERP are you using, and for which views and fields you had to modify the js to fix it ?
Hi Yannick
Thanks a lot for your quick reply.
But it’s still not working for me.
I use a nightly build of the OpenERP server (openerp-6.1-20120617-233256) and the latest versions of the module web_wysiwyg (your fix is included, I checked it).
It’s also not working, if I switch the WYSIWYG off before saving the invoice line.
There is a strange behaviour:
- I open an invoice
- I open an invoice line
- I switch the WYSIWYG on
- I edit the text
- I switch the WYSIWYG off (I can see the correct content in the textbox)
- I click ‘save & close’
- I think, the save button of the invoice should be red. But it isn’t.
- If I reopen the invoice line (without saving the invoice before), my changes in the text are lost.
Do you have an idea whats wrong? Which versions are you using?
Thx
Hi,
I tried your case on 6.1 and works fine for me. By the way, those buttons are never red.
So could you check if your file “web_wysiwyg/static/src/js/web_wysiwyg.js” got a line like this =>
$(‘button.oe_form_button_save, button.oe_selectcreatepopup-form-save, button.oe_selectcreatepopup-form-save-new’).unbind(‘click’, handler);
Hi,
Yes this line is existing (Line 27).
Is this good or bad?
Excelente!!!
Great addon! Thank you very much!
Hello
Does anyone have news on my problem?
I have installed the nightly build openerp-6.1-20120830-233304 of the OpenERP-Server and the revision Rev 5 of the web_wysiwyg and web_display_html.
I have still the following problem:
- I change the Text (WYSIWYG is on) in the account.invoice.line, save the line and save the invoice. My changes are missing.
Also setting the WYSIWYG to off before saving the line and the invoice will ignore my changes.
Have anyone an idea?
Or how can we proceed?
Is there a possibility for debugging?
Thanks a lot for quick reply.
@FRED
Hello,
I had the same problem and I resolve it with this change in file web_wysiwyg/static/src/js/web_wysiwyg.js :
Line 27 :
//$(‘button.oe_form_button_save, button.oe_selectcreatepopup-form-save, button.oe_selectcreatepopup-form-save-new’).unbind(‘click’, handler);
$(‘button.oe_button, button.oe_formopenpopup-form-save’).unbind(‘click’, handler);
Line 49 :
//$(‘button.oe_form_button_save, button.oe_selectcreatepopup-form-save, button.oe_selectcreatepopup-form-save-new’).prependEvent(‘click’, handler);
$(‘button.oe_button, button.oe_formopenpopup-form-save’).prependEvent(‘click’, handler);
Line 70 :
//$(‘button.oe_form_button_save, button.oe_selectcreatepopup-form-save, button.oe_selectcreatepopup-form-save-new’).unbind(‘click’, handler);
$(‘button.oe_button, button.oe_formopenpopup-form-save’).unbind(‘click’, handler);
I hope it can help you
Hello Loïc
It works also on my system.
Thanks a lot for posting your bugfix.
Bye
Pressing the button I get this error:
toggle_ckeditor is not defined
Someone happened to him? is as if it were loaded web_wysiwyg.js
Hi Gabriel,
toggle_ckeditor() function is defined in ~/static/src/js/web_wysiwyg.js and should be loaded once the addon is installed.
May be try to clear your web browser Cache (Ctrl+Shift+Del) and refresh the page to force the loading of javascript.
Dear Yannick,
This a nice addon, but I have two problems.
Both modules installed, button, widget added to the view, I use OpenERP 6.1.1 on Windows.
1. The wysiwyg editor line not show up when I push the button (the button itself change from wysiwyg on to wysiwyg off)
2. If I put html code to the product sales description, it works fine on the form page, but the html tags appear on the pdf of the sales orders.
Any advice would be appreciated…
Sorry, in the meantime the wysiwyg started to loading.
But if you would advice me in the 2. question, that would nice.
Szolo
Hi Szolo,
Could you pleease tell me which kind of report you use for the Sale order ?
Webkit, RML, aeroo ?
Dear Yannick,
RML with OpenOffice editing.
Do you think, the case is different if I use something else?
To have html formatted product descriptions is very important to us.
Any suggestion is appreciated!
html tags will appear as is in RML.
The Webkit report engine sould be able to interpret them properly.
Dear Eric,
* Do you know how I link a image that was uploaded to the ERP server?
* Is there any posibility to allow the CKeditor to be enabled for style such as Headings?
Thanks
Etienne
Nice extension, works great.
Is it possible to start with wysiwyg_on = true.
I would like to remove the switching button as my users are scared by the html tags they see when editing a record.
Can you help me?
I managed to get it.
Here is the way I used:
web_wysiwyg.js is now:
var wysiwyg_on = false;
// function which will save the content of the WYSIWYGs into the textareas
var handler = function(){
if(wysiwyg_on){
$(‘textarea’).trigger(‘change’);
// Here we transform all the WYSIWYG textareas into regular textareas
$(‘textarea’).each(function(){
try {
$(this).ckeditorGet().updateElement();
}
catch(e) { }
});
// Remove onclick event on save button.
$(‘button.oe_form_button_save, button.oe_selectcreatepopup-form-save, button.oe_selectcreatepopup-form-save-new’).unbind(‘click’, handler);
wysiwyg_on = false;
}else{
return true;
}
}
openerp.web_wysiwyg = function(openerp) {
openerp.web.FormView.include({
on_record_loaded: function(record) {
// Here we transform all the regular textareas into WYSIWYG textareas
$(‘textarea.field_text_WYSIWYG’).ckeditor({ toolbar : ‘Mine’ });
// Add onclick event on save button.
$(‘button.oe_form_button_save, button.oe_selectcreatepopup-form-save, button.oe_selectcreatepopup-form-save-new’).prependEvent(‘click’, handler);
wysiwyg_on = true;
return this._super(record)
}
});
}
Also no need to add the html button, of course.
May be this can interest someone.
Pierre