The FLEET module has a list of service types
class fleet_service_type(osv.Model):
_name = 'fleet.service.type'
_description = 'Type of services available on a vehicle'
_columns = {
'name': fields.char('Name', required=True, translate=True),
'cost':fields.float('Cost Of Service',required=True),
'category': fields.selection([('contract', 'Contract'), ('service', 'Service'), ('both', 'Both')], 'Category', required=True, help='Choose wheter the service refer to contracts, vehicle services or both'),
}
fleet_service_type()
i want to have a field in my sale.order module that will be the dropdownlist of all 'name' values in the fleet module. Can anyone suggest how to i do that
For get all value of relationship object (Fleet Service Type), you need to add many2one relationship
on Sale Order
with target object.
Put this code in your .py
file
class sale_order(osv.Model):
_inherit = 'sale.order'
_columns = {
'fleet_id': fields.many2one('fleet.service.type', 'Fleet Service Type'),
}
And do some customization on view xml file
.
<record id="view_sale_order_extended_form1" model="ir.ui.view">
<field name="name">sale.order.form1.extend</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<field name="partner_id" position="before">
<field name="fleet_id"/>
</field>
</field>
</record>
After this you can see field Fleet Service Type
after Customer
field in Sale Order Form.
And you can select your desire value of Fleet Service Type
.
Hope this will help you.