[FIX]Odometer graph + operator to max operator. + replace month field by date field for graphs

bzr revid: dle@openerp.com-20121001123652-bxpvk199pz0mow58
This commit is contained in:
Denis Ledoux dle@openerp.com
2012-10-01 14:36:52 +02:00
parent 028e36016c
commit 693fa51ca5
2 changed files with 7 additions and 25 deletions
+2 -18
View File
@@ -297,31 +297,15 @@ class fleet_vehicle_odometer(osv.Model):
def _vehicle_log_name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
res = self.name_get(cr, uid, ids, context=context)
return dict(res)
def get_month(self, cr, uid, ids, context=None):
if context is None:
context = {}
if not ids:
return []
months = ['January','February','March','April','May','June','July','August','September','October','November','December']
reads = self.browse(cr, uid, ids, context=context)
res = []
for record in reads:
res.append((record.id,months[int(record.date.split('-')[1])-1]))
return res
def _vehicle_log_month_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None):
res = self.get_month(cr, uid, ids, context=context)
return dict(res)
_columns = {
'name' : fields.function(_vehicle_log_name_get_fnc, type="char", string='Name', store=True),
'date' : fields.date('Execution Date'),
'value' : fields.float('Odometer Value'),
'value' : fields.float('Odometer Value',group_operator="max"),
'unit': fields.related('vehicle_id','odometer_unit',type="char",string="Unit",store=False, readonly=True),
'vehicle_id' : fields.many2one('fleet.vehicle', 'Vehicle', required=True),
'month' : fields.function(_vehicle_log_month_get_fnc,string="Month", type="char",size=32, store=True)
}
_defaults = {
'date' : time.strftime('%Y-%m-%d')
+5 -7
View File
@@ -287,7 +287,6 @@
<menuitem name="Vehicles" parent="menu_root" id="fleet_vehicles" />
<menuitem action="fleet_vehicle_act" parent="fleet_vehicles" id="fleet_vehicle_menu" />
<record model='ir.ui.view' id='fleet_vehicle_log_insurance_form'>
<field name="name">fleet.vehicle.log_insurance.form</field>
<field name="model">fleet.vehicle.log.insurance</field>
@@ -386,9 +385,9 @@
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Odometer value per month">
<field name="month" />
<field name="date" />
<field name="vehicle_id" group="True" />
<field name="value" operator="+"/>
<field name="value" />
</graph>
</field>
</record>
@@ -453,7 +452,6 @@
<field name="unit" />
<field name="inv_ref" />
<field name="vendor_id" />
<field name="month" invisible="1"/>
</tree>
</field>
</record>
@@ -463,8 +461,8 @@
<field name="model">fleet.vehicle.log.fuel</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Odometer value per month">
<field name="month" />
<graph string="Total Fuel amount per month">
<field name="date" />
<field name="vehicle_id" group="True" />
<field name="amount" operator="+"/>
</graph>
@@ -540,7 +538,7 @@
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Services total amount per month">
<field name="month" />
<field name="date" />
<field name="vehicle_id" group="True" />
<field name="amount" operator="+"/>
</graph>