[ADD]On change model : change logo of brand
bzr revid: dle@openerp.com-20120928114210-7tq19ednxuf47qg4
This commit is contained in:
+14
-12
@@ -43,6 +43,19 @@ class fleet_vehicle_model(osv.Model):
|
||||
res = self.name_get(cr, uid, ids, context=context)
|
||||
return dict(res)
|
||||
|
||||
def on_change_brand(self, cr, uid, ids, model_id, context=None):
|
||||
|
||||
if not model_id:
|
||||
return {}
|
||||
|
||||
brand = self.pool.get('fleet.vehicle.model.brand').browse(cr, uid, model_id, context=context)
|
||||
|
||||
return {
|
||||
'value' : {
|
||||
'image' : brand.image,
|
||||
}
|
||||
}
|
||||
|
||||
_name = 'fleet.vehicle.model'
|
||||
_description = 'Model of a vehicle'
|
||||
|
||||
@@ -177,26 +190,15 @@ class fleet_vehicle(osv.Model):
|
||||
}
|
||||
|
||||
def on_change_model(self, cr, uid, ids, model_id, context=None):
|
||||
# print "ids: %r" % (ids,)
|
||||
# print "model_id: %r" % (model_id,)
|
||||
# print "context: %r" % (context,)
|
||||
# import logging
|
||||
# logger = logging.getLogger('fleet.vehicle')
|
||||
# logger.info('Hello')
|
||||
|
||||
# import ipdb
|
||||
# ipdb.set_trace()
|
||||
|
||||
if not model_id:
|
||||
return {}
|
||||
|
||||
model = self.pool.get('fleet.vehicle.model').browse(cr, uid, model_id, context=context)
|
||||
|
||||
print "model: %r" % (model.name,)
|
||||
|
||||
return {
|
||||
'value' : {
|
||||
'message' : "You have selected this %s model" % (model.name,),
|
||||
'image' : model.image,
|
||||
}
|
||||
}
|
||||
def create(self, cr, uid, data, context=None):
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<field name="image" widget='image' class="oe_left oe_avatar"/>
|
||||
<group col="2">
|
||||
<group>
|
||||
<field name="brand" />
|
||||
<field name="brand" on_change="on_change_brand(brand)"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="modelname" />
|
||||
@@ -100,16 +100,14 @@
|
||||
<div class="oe_title">
|
||||
<label for="model_id" class="oe_edit_only"/>
|
||||
<h1>
|
||||
<field name="model_id" class="oe_inline"/>
|
||||
<field name="model_id" class="oe_inline" on_change="on_change_model(model_id)"/>
|
||||
</h1>
|
||||
<label for="license_plate" class="oe_edit_only"/>
|
||||
<h2>
|
||||
<field name="license_plate" class="oe_inline"/>
|
||||
</h2>
|
||||
|
||||
<label for="tag_ids" class="oe_edit_only"/>
|
||||
<field name="tag_ids" widget="many2many_tags" />
|
||||
|
||||
</div>
|
||||
<div class="oe_right oe_button_box">
|
||||
<button name="act_show_log_insurance" type="object" string="Insurances" help="show the insurance for this vehicle" />
|
||||
@@ -187,7 +185,7 @@
|
||||
<div class="oe_vehicle_desc">
|
||||
<h4><a type="open"><field name="license_plate"/></a></h4>
|
||||
<p>
|
||||
<field name="model_id"/><br/>
|
||||
<field name="model_id" on_change="on_change_model(model_id)"/><br/>
|
||||
<t t-if="record.driver.raw_value"><field name="driver"/><br/></t>
|
||||
<t t-if="record.location.raw_value"><field name="location"/><br/></t>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user