Create a new module, say 'sale_customization
' in the addons directory and create __init__.py
and __openerp__.py
files in the module.
Then create a file sale.py
in it and add the following code:
from openerp.osv import fields,osv
class sale_order(osv.osv):
_inherit = 'sale.order'
_columns = {
'field1': fields.char('Field1', size=64),
'make_of_car': fields.selection([('make1', 'Make1'), ('make2', 'Make2')] ,'Make of the Car', required=True),
'model_of_car': fields.selection([('model1', 'Model1'), ('model2', 'Model2')] ,'Model of the Car', required=True),
}
sale_order()
Now add the line import sale
in __init__.py
file.
Then create a file sale_view.xml
in the module and add the following in it:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form.1</field>
<field name="model">sale.order</field>
<field name="type">form</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='origin']" position="after">
<field name="field1"/>
<field name="make_of_car"/>
<field name="model_of_car"/>
</xpath>
</data>
</field>
</data>
</openerp>
Now add the following to the __openerp__.py
file.
{
"name" : "Sale Customization",
"version" : "1.0",
"author" : "Gopakumar N G",
"website" : "http://www.zbeanztech.com",
"category" : "Custom",
"depends" : ["sale"],
"description": """ Sale customizations """
'init_xml': [],
'update_xml': [
'sale_view.xml',
],
'demo_xml': [
],
'test': [
],
'installable': True,
'active': False,
}
Now restart the server and update the module list in Administration->Modules->Update Module List
, the in Installed Modules
menu uncheck the 'Installed' filter and select your module and install it.