Odoo Help
Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM
|
e-Commerce
|
Accounting
|
Inventory
|
PoS
|
Project management
|
MRP
|
etc.
error: Some modules could not be started
trying to add my custom markdown editor in odoo9 for text area.
Below is the code for widget_text_markdown.js::
odoo.define('web_widget_text_markdown',function (require) {
var core = require('web.core');
var formats = require('web.formats');
var common = require('web.form_common');
var _lt = oe.web._lt;
//oe.web.form.widgets.add('bootstrap_markdown', 'openerp.web_widget_text_markdown.FieldTextMarkDown');
var FieldTextMarkDown = common.AbstractField.extend(common.ReinitializeFieldMixin, {
template: "FieldMarkDown",
display_name: _lt('MarkDown'),
internal_format: 'field_text',
widget_class: 'oe_form_field_bootstrap_markdown',
events: {
'change input': 'store_dom_value' ,
},
init: function (field_manager, node) {
this._super(field_manager, node);
this.$txt = false;
this.internal_set_value(0);
},
parse_value: function(val, def) {
return formats.parse_value(val, {"widget": this.internal_format}, def);
},
initialize_content: function () {
// Gets called at each redraw of widget
// - switching between read-only mode and edit mode
// - BUT NOT when switching to next object.
if(!this.get("effective_readonly")) {
this.$el.find('input').markdown(this.options);
this.setupFocus(this.$('input'));
}
},
store_dom_value: function () {
if (!this.get('effective_readonly')) {
this.internal_set_value(
this.parse_value(
this.$('input').val(),''));
}
},
commit_value: function () {
this.store_dom_value();
return this._super();
},
_get_raw_value: function() {
if (this.$txt === false)
return '';
return this.$txt.val();
},
render_value: function () {
// Gets called at each redraw/save of widget
// - switching between read-only mode and edit mode
// - when switching to next object.
var show_value = this.format_value(this.get('value'), '');
if (!this.get("effective_readonly")) {
this.$input = this.$el.find('input');
this.$input.val(show_value);
} else {
// avoids loading markitup...
marked.setOptions({
highlight: function (code) {
return hljs.highlightAuto(code).value;
}
});
this.$(".oe_form_text_content").html(marked(show_value));
}
},
format_value: function (val, def) {
return formats.format_value(val, {"widget": this.internal_format}, def);
},
});
core.form_widget_registry.add('bootstrap_markdown', FieldTextMarkDown);
return {
FieldTextMarkDown: FieldTextMarkDown,
};
});
After adding this widget to my field it is showing js error that module failed loading
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.
RegisterOdoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it nowQuestion tools
Stats
Asked: 8/24/16, 10:56 AM |
Seen: 2095 times |
Last updated: 4/25/17, 11:56 PM |
Geetha, try to debug it from console using "Inspect Element" of your browser and check for the error, that would help you to find out the exact error in your js code..