Hi Ehab Mosilhy,
Tables are get created in database from class we written in python code. And fields in the tables are the one we write in _columns in that class.
eg:
class sale_order(osv.osv):
_name = "sale.order"
_columns = {
'name': fields.char('Order Reference', size=64, required=True,
readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
...........
}
sale_order()
Fields write in xml file is only for view purpose.
To add or modify the table or view, inherit the class and add new fields. If you want to show the fields in view, then inherit the view(xml) and add the new field in view too.
eg:
class sale_order(osv.osv):
_inherit = 'sale.order'
_columns = {
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
'categ_ids': fields.many2many('crm.case.categ', 'sale_order_category_rel', 'order_id', 'category_id', 'Categories', \
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]", context="{'object_name': 'crm.lead'}")
}
Its added in view.
<record model="ir.ui.view" id="sale_view_inherit123">
<field name="name">sale.order.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="section_id" widget="selection"/>
<field name="categ_ids" widget="many2many_tags"/>
</field>
</field>
</record>