Monday, 23 May 2016

Add field with Position Odoo


Hello world. Today i am gonna show you how to add custom field with position odoo. The last post i just share about add field odoo 'after'. In this post i will show you how implementation position add field odoo. Now i still use odoo 9 and module  'Dedy Custom Fields Product' . lets code !!

https://dedyyuristiawan.blogspot.co.id
View Product Odoo

1. Position = "before"
This is my form view product, now i will put my field before product type. i just use code like this. i will put my field before Product type.

<record id="add_field_product_form" model="ir.ui.view">  
     # For the tree view and id field (whatever)
      <field name="name">add.field.product.form</field>  
      # Name field (whatever)
      <field name="model">product.template</field>  
      # Parent object
      <field name="inherit_id" ref="product.product_template_only_form_view">
      # Parent View
      <field name="arch" type="xml">
      <xpath expr="//field[@name='type']" position="before">
  # Name field and Position (after)
        <field name="info">      
         # Your new Field
      </field></xpath>
      </field>
</field></record> 
similar like form view, i want change my tree view and just code like this 

<record id="add_field_product_tree" model="ir.ui.view">            
     # For the tree view and id field (whatever)
         <field name="name">add.field.product.tree</field>
         # Name field (whatever)
         <field name="model">product.template</field>  
         # Parent object
         <field name="inherit_id" ref="product.product_template_tree_view">
         # Parent View
         <field name="arch" type="xml">
     <xpath expr="//field[@name='type']" position="before">
     # Name field and Position (after)
       <field name="info">      
       # Your new Field
             </field></xpath>
         </field>
     </field></record>
and finally my form and tree view like this

https://dedyyuristiawan.blogspot.co.id
View Add Position Before



2. Position = "replace"

This is my form view product, now i will put my field before product type. i just use code like this. . i will put my field replace internal reference.

<record id="add_field_product_form" model="ir.ui.view">  
     # For the tree view and id field (whatever)
      <field name="name">add.field.product.form</field>  
      # Name field (whatever)
      <field name="model">product.template</field>  
      # Parent object
      <field name="inherit_id" ref="product.product_template_only_form_view">
      # Parent View
      <field name="arch" type="xml">
      <xpath expr="//field[@name='default_code']" position="replace">
  # Name field and Position (after)
        <field name="info">      
         # Your new Field
   </field></xpath>
      </field>
     </field></record> 
similar like form view, i want change standard price my tree view and just code like this 

<record id="add_field_product_tree" model="ir.ui.view">            
     # For the tree view and id field (whatever)
         <field name="name">add.field.product.tree</field>
         # Name field (whatever)
         <field name="model">product.template</field>  
         # Parent object
         <field name="inherit_id" ref="product.product_template_tree_view">
         # Parent View
         <field name="arch" type="xml">
     <xpath expr="//field[@name='standard_price']" position="replace">
     # Name field and Position (after)
       <field name="info">      
       # Your new Field
             </field></xpath>
         </field>
     </field></record>
and finally my form and tree view like this

https://dedyyuristiawan.blogspot.co.id
View Replace Field Odoo


And the conclusion is still like prev post you must know parent object, parent view, and position. you can use after, before, and replace. If you have any question just write comment, i will help if i can help you. Don't forget to be happy world. Thanks.
Share:
Lokasi: Semarang, Semarang City, Central Java, Indonesia

13 comments:

  1. Good article .also check my blog guys mainly about odoo http://akhmadkresna.github.io

    ReplyDelete
  2. Hi Dedy, Can you please explain what are product.product_template_tree_view and product.product_template_only_form_view over here.

    ReplyDelete
  3. Great information. I have just written same article on my blog. I would like you to read this post and get me the quality level of this post. I think you are the right person who can get me the right feedback. http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

    ReplyDelete
  4. Seems like you are fond of writing since a long, therefore your posted content is well formulated in a proper way of writing. It's an amazing experience to read your blog post as you have shared a piece of meaningful and required information with the use of proper statics and beautiful words. Thanks for sharing!!
    Hire Odoo developers India

    ReplyDelete
  5. Fantastic post.

    Really enjoyed reading it and it held my attention all the way through! Keep it up.

    Read my Latest Post

    ReplyDelete
  6. Nice article. This article is very helpful for me . If you want to change your text into different fonts then visit our website https://www.savetube.cc/instagram-font-generator.

    ReplyDelete
  7. Great Post!!!!

    Thank you so much for sharing your wonderful thoughts regarding Odoo. It is very unique and wonderful. Keep sharing.

    ReplyDelete
  8. Thank you for sharing such an wonderful piece of information with us. The content is really very helpful. I hope that you will share some more in near future.
    Odoo Consulting Service

    ReplyDelete
  9. Great article! Thanks for sharing this informative article. Looking for the best Digital Transformation Company in Australia? Reach IDYA Technology.

    ReplyDelete
  10. Nice article. Thank you for sharing such informative blog.
    Visit Mobibiz a leading mobile app development company in Gurgaon offers mobile and web development services for its regional and global clients. We deliver scalable and robust mobility solutions for all business segments.

    ReplyDelete


<br>


Advice for contacting me at dedyy54@gmail.com