Thursday 19 April 2012

How to Add custom Widget in your open ERP module

How to Add custom Widget in your open ERP module ..
 Here are steps : 
                                                        By : Pinakin Nayi
                                                               Trainee OpenERP,
                                                               Gandhinagar.
                                                               E-mail : nayi_pinakin@yahoo.in
Step 1 :
          create a folder
                   --> static
                            --> src
                                   -->js
                                        ->lib.js
                                  --> xml
                                        -> lib.xml
                                  --> css
                                        -> .css

Step 2 :
          Register your xml file in __openerp__.py
          Like this
                      'css': [ 'static/src/css/resource.css' ],
                      'js': [  'static/src/js/lib.js' ],
                       'qweb' : [ 'static/src/xml/lib.xml', ],

Step 3 : 
        In  "lib.xml"  create your template
           like ,
                    <templates id="template" xml:space="preserve">
                     <t t-name="link">
                      <div>manage your template  </div>
                    </t>
                  </templates>

Step 4 :
      In  "lib.js"  create your template
           like ,

                      openerp.lib = function(instance)
                     {
                       console.log('tTTT',instance)
                       instance.web.form.widgets.add('link', 'openerp.lib.Mywidget');
                       instance.lib.Mywidget = instance.web.form.Widget.extend( {
                              template : 'link',
                              init : function(arg)
                                             {
                              console.log('initi....my custome widget');
                              }
                      })
                  }

Step 5 : 
       In this test i have only write "manage your template" instread of that you can
      write your own template to implement ..

Step 6 : 
         Now , your Widget is ready ,
         you have to implement this in your tag.

        <field name="description" colspan="4" widget="link" />


9 comments:

  1. A Magento side extension and an Open ERP side module. The Magento extension is a PHP based web services improvement which is fully written and maintained by Openlabs.

    ERP Modules

    ReplyDelete
  2. I have this error : View error

    Can't find field 'xxx' in the following view parts composing the view of object model xxxxxxxx':
    * xxxxxxxxxxxxx

    Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model



    I have to put the field on the colomn of my class ?

    ReplyDelete
  3. Ya, U will get this. Bcz u are testing my widget in  v6.1 but i had made it for the v6.2 or latest so try in that.

    ReplyDelete
  4. Add your field in py file

    ReplyDelete
  5. Thanks for pointing that out. This good example of adding custom widget in open ERP module.ERP module List consists of many important modules that will make organizations run their business process.

    ReplyDelete
  6. how can i remove control panel in odoo?

    ReplyDelete
  7. Nice blog, very interesting to read
    I have bookmarked this article page as i received good information from this.

    Cloud Based ERP Software in India

    ERP Software Providers in Hyderabad

    ERP Software Company in Hyderabad

    ReplyDelete
  8. Really good work there. Informative and helpful. Appreciate it. But might be looking for Odoo Customization Services in Pennsylvania

    ReplyDelete