Odoo Help


Odoo9c: Creating widget not recognize (can't be used by widget="char2")

Prihadi Ramadhany
on 10/17/16, 9:58 AM 603 views

Hi Community,

I'am creating a widget (using Odoo 9c) which modified from Odoo 9c documentation (section: "Creating a New Type of Field"), and give name 'char2' widget.  I put in use on my form with <field name="...." widget="char2"/> but it not working/no effect.  The field type that I'm gonna use the widget with is Char.

On the form, I went developer mode and manage view, then look at the field properties, I can't find 'char2'  (for that field) on the widget dropdown list.

Is anything I missed here?  Any help will be very appreciated.

Below is the widget's JS

openerp.energy_survey = function(instance, local)
var QWeb = instance.web.qweb;

local.FieldChar2 = instance.web.form.AbstractField.extend(
init: function()
this._super.apply(this, arguments); this.set("value", ""); },
start: function()
this.on("change:effective_readonly", this, function()
 this.display_field(); this.render_value(); }); this.display_field(); return this._super(); },
 display_field: function()
 var self = this; this.$el.html(QWeb.render("FieldChar2", {widget: this})); if (! this.get("effective_readonly"))
 self.internal_set_value(self.$("input").val()); }); }
render_value: function()
if (this.get("effective_readonly"))
 this.$el.text(this.get("value")); } else {
 this.$("input").val(this.get("value")); }
  }); instance.web.form.widgets.add('char2', 'instance.energy_survey.FieldChar2'); }

here is __openerp__.py

'data': [	    
 'js': [
 'demo': [
 'qweb': [
'css': [


@charset "UTF-8";

 margin: 5px;
padding: 5px;
border-radius: 3px;
background-color: #F0EEEE;

here is the template XML  

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="FieldChar2">
 <div class="oe_field_char2">
 <t t-if="! widget.get('effective_readonly')">
 <input type="file" accept="image/*" capture="camera"></input>

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/17/16, 9:58 AM
Seen: 603 times
Last updated: 10/17/16, 10:36 AM