View Product Odoo |
1. Activate the Developer Mode
Open help menu - about - activate the developer mode
Activate Developer Mode |
2. Find Field Name Want You Put your new Field
After you activate the developer mode, we can know name of the field, and the way to know name of filed is just put your cursor to field.
Find Field Name |
3. Find Parent Object and Parent View
Remember in this tutorial i will put my new field, after Product Type field. To find parent object and parent view just click Open debug menu (top right corner) - Edit form view and you will see view like this.
View Edit Form View Odoo |
As you can see product.template is parent object and product.product_template_only_form_view is parent view. After you know name field, parent object and parent view we can begin with the code.
4. Create Folder and 4 File inside the folder
i just create folder and give name dedy_custom_field, 4 file is __init__.py , __openerp__.py , add_field_product_view.xml , add_field_product.py.
__init__.py
import add_field_product # Name file py
Its just import file py that your have created.
__openerp__.py
{ 'name' : 'Dedy Custom Fields Product', # Name App 'version' : 'v.1.0', # No Version 'summary' : 'Dedy Custom Fields Product', # Name Sumary 'sequence' : 1, # No App 'author' : 'Dedy Yuristiawan', # Name Author 'description' : """ author : Dedy Y v.1.0 : \n This module for add additional fields in Product\n """, # Name description 'category' : 'field', # Name category 'depends' : ['base','product'], # Name point parent 'data' : [ 'add_field_product_view.xml', ], # Name file xml 'installable' : True, 'application' : True, 'auto_install' : False }The point from this file is depends (from parent object), data (file xml), and name app.
add_field_product.py
add_field_product.py from openerp import tools from openerp import models, fields, api from pygments.lexer import _inherit class AddFieldProduct (models.Model):# Name class _inherit = "product.template" # Name parent object info = fields.Char('Info') # Name field want you show to your xml with char typeThe point from this file is name parent object and variable field
add_field_product_view.xml
<openerp> <data> <record model="ir.ui.view" id="add_field_product_tree"> # 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="after"> # Name field and Position (after) <field name="info"/> # Your new Field </xpath> </field> </record> <record model="ir.ui.view" id="add_field_product_form"> # 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="after"> # Name field and Position (after) <field name="info"/> # Your new Field </xpath> </field> </record> </data> </openerp>
The point from this file is name (its whatever), model (from parent object), inherit_id (from parent view), Name field from odoo (@name='type') and name field that you already created.
After you already create 4 file and then put into folder addons odoo.
5. Update App List
App - Update App List
6. Find Your App
Apps - Apps
View Apps Odoo |
choose your app (Dedy Custom Field Product) that your already created. and then install.
7. See What's Happen
And now we done with this one, we success for add field into or modification Odoo.
The conclusion is if you want to add field you must know parent object, parent view, and field nearest. After you know it, you can modification odoo. next post i will share about position want you put your field.
If you have any question just write comment, i will help if i can help you. Don't forget to be happy world. Thanks
Wah masnya hebat.. pasti karyawan PCI wkwk
ReplyDeletemas kan guru saya ehehe
DeleteThank you such a good blog on odoo. It give a good information on how to create field in odoo form.
ReplyDeleteYour welcome, I love learn and share each other :-P
Deletebroo kalo saya mau rubah tampilan report di customer invoice, gimana tuh? yg harus di inherit apaa? trus skalian mau rubah ukuran kertasnya gimana caranya??
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGood article .also check my blog guys mainly about odoo http://akhmadkresna.github.io
ReplyDeleteThanks a lot man! You are awesome! Very easy and helpful for us. Please keep doing this blog about odoo. Your tutorials is good and much informative.
ReplyDeleteProbado en versiĆ³n 11 y OK.
ReplyDeleteThanks for posting this info regarding odoo. I just want to let you know that I have checked out your site and I found it very interesting and informative.
ReplyDeleteOdoo development
Thank you for sharing this article I was searching this for a long time.
ReplyDeleteOdoo development company.
Great Article!!!!
ReplyDeleteThank you so much for sharing such an amazing piece of information with us regarding Odoo. It is very unique and informational. Keep sharing.Odoo e-Commerce
Informative and helpful Article. Really good work. Appreciate it. You might be looking for Open Source Software Solutions in Bangalore
ReplyDeleteVery informative article! Thanks for sharing this informative article. Looking for the best AR App Developers in Australia? Reach IDYA Technology.
ReplyDeleteGreat guide on adding fields in Odoo! Super helpful for any odoo development companylooking to customize their modules and improve workflow efficiency.
ReplyDelete