Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Sales order custom fields

By
Darren
on 1/9/14, 3:54 PM 1,362 views

Can anyone help, we have been looking at using openerp 7 in our company, what we have looking to do is add some custom fields in the sales order and manufacture orders. Up to 3 searchable boxes but 2 of them to be drop down boxes to allow you to select make of car and model of car. As we are a vehicle based company that need to show vehicle data and it be searchable. Can anyone help with this

Thanks

2

Gopakumar N G

--Gopakumar N G--
1198
| 5 3 7
Cochin, India
--Gopakumar N G--

Senior Software Engineer at BroadTech IT Solutions Pvt. Ltd.

Gopakumar N G
On 1/10/14, 2:00 AM

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.

Many thanks for your info will give it a try

Darren
on 1/10/14, 2:25 PM

I need add custom fields "estampacion, marquilla, insumos y empaque", all contain sub fields how i do that?

Jhon Felipe Urrego Mejia
on 2/26/14, 4:49 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 1/9/14, 3:54 PM
Seen: 1362 times
Last updated: 3/16/15, 8:10 AM