Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4203 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

Many thanks for your info will give it a try

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