Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
32712 มุมมอง

I've read that if I'd like to customize or add a field to any app/module, it's better to do that by creating my own module to do that. But I'd like to ask, how to create a module that adds a field to another module?

I've read about module creation but it didn't answer my question

อวตาร
ละทิ้ง

OpenERP and partners propose formation to create your own module. Just one day can be a good bootstrap

คำตอบที่ดีที่สุด

You can add extra fields Through UI or By a new custom module, which should inherit the parent model need to be customized. Odoo have an inbuilt structure to make a plugin, you can find more information form odoo docs. 

For Customization

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

The best way to learn how to create a custom module and to inherit other modules is to go through the Odoo's official documentation. Please go through the below link to find more info on this

https://www.odoo.com/documentation/12.0/howtos/backend.html#build-an-odoo-module

If you need more help with odoo customization you can talk to our odoo consultant or hire an odoo developer  ​for more help 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You have to create the __init__.py file and __openerp__.py (look for samples on line). Than a simple module can be

import osv..... import date (if you need it or import any other library you think you will need)

class product_product2 (osv.osv):
    _name = 'product.product2' (this is the name of your module)
   _inherit = 'product.product' (this is the product you wish your module to behave like and you want to add your new fields to)
   columns = {tests: fields.char('Test Field', size = 128)}#this will contain all the new fields you want to add to the product module you are inheriting from it also contains the type #of content that goes into the field, eg char for character, integer for numbers float for floating numbers basically you typical database system

product_product2() states the end of a module also this closes the module so you can start another module

your _view.xml can look like

 <openerp>
      <data>
                <record id="view_order_label_form_change" model="ir.ui.view">
                     <field name="name">product.product2_form</field>
                     <field name="model">product.product</field>
                     <field name="inherit_id" ref="product.product_normal_form_view"/> <!--not sure if this is correct but looks like that-->
                     <field name="arch" type="xml">       
                               <field name="name" position="after"> <!--this is saying look for field name in product and add my field after it-->
                                        <field name = "tests" select="1"/> <!--add select if you want your field searchable -->
                               </field>
                    </field>
    </data>
</openerp>

Hope this helps you a bit

อวตาร
ละทิ้ง

to complete Kaynis, you have here the basic information to create a module http://dipleo.fr/module-creation-bases/ I will write a tutorial about ihnerit tomorrow.

คำตอบที่ดีที่สุด

Hi OpenERP and partners propose formation to create your own module. Just one day can be a good bootstrap

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 24
1239
3
มิ.ย. 24
2443
0
พ.ย. 23
918
2
ก.พ. 25
3049
How to add simple birthday field? แก้ไขแล้ว
2
ส.ค. 23
2082