Skip to content

Commit

Permalink
[ADD]change in contract view and model
Browse files Browse the repository at this point in the history
bzr revid: csn@openerp.com-20121004102033-mr108oy63dnmxlik
  • Loading branch information
csnauwaert committed Oct 4, 2012
1 parent 8e7e767 commit 1697d61
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 42 deletions.
12 changes: 0 additions & 12 deletions addons/fleet/demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1846,18 +1846,6 @@ gg==
<field name="sequence">4</field>
</record>

<record id="vehicle_contract_type_bigrisks" model="fleet.contract.type">
<field name="name">Insurance</field>
</record>

<record id="vehicle_contract_type_smallrisks" model="fleet.contract.type">
<field name="name">Leasing</field>
</record>

<record id="vehicle_contract_type_omium" model="fleet.contract.type">
<field name="name">Omium</field>
</record>

<record id="vehicle_1" model="fleet.vehicle">
<field name="license_plate">1-ACK-205</field>
<field name="vin_sn">5454541</field>
Expand Down
38 changes: 14 additions & 24 deletions addons/fleet/fleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def get_overdue_contract_reminder(self,cr,uid,ids,prop,unknow_none,context=None)
reads = self.browse(cr,uid,ids,context=context)
res=[]
for record in reads:
contracts = self.pool.get('fleet.vehicle.log.contract').search(cr,uid,[('vehicle_id','=',record.id),('state','=','open'),('reminder','=',True)],order='expiration_date')
contracts = self.pool.get('fleet.vehicle.log.contract').search(cr,uid,[('vehicle_id','=',record.id),('state','=','open')],order='expiration_date')
overdue=0
if (len(contracts) > 0):
for element in contracts:
Expand Down Expand Up @@ -271,7 +271,7 @@ def get_next_contract_reminder(self,cr,uid,ids,prop,unknow_none,context=None):
reads = self.browse(cr,uid,ids,context=context)
res=[]
for record in reads:
contracts = self.pool.get('fleet.vehicle.log.contract').search(cr,uid,[('vehicle_id','=',record.id),('state','=','open'),('reminder','=',True)],order='expiration_date')
contracts = self.pool.get('fleet.vehicle.log.contract').search(cr,uid,[('vehicle_id','=',record.id),('state','=','open')],order='expiration_date')
due_soon=0
if (len(contracts) > 0):
for element in contracts:
Expand Down Expand Up @@ -726,19 +726,19 @@ def get_warning_date(self,cr,uid,ids,prop,unknow_none,context=None):
reads = self.browse(cr,uid,ids,context=context)
res=[]
for record in reads:
if (record.reminder==True):
if (record.expiration_date and record.state=='open'):
today=self.str_to_date(time.strftime('%Y-%m-%d'))
renew_date = self.str_to_date(record.expiration_date)
diff_time=int((renew_date-today).days)
if (diff_time<=0):
res.append((record.id,0))
else:
res.append((record.id,diff_time))
#if (record.reminder==True):
if (record.expiration_date and record.state=='open'):
today=self.str_to_date(time.strftime('%Y-%m-%d'))
renew_date = self.str_to_date(record.expiration_date)
diff_time=int((renew_date-today).days)
if (diff_time<=0):
res.append((record.id,0))
else:
res.append((record.id,-1))
res.append((record.id,diff_time))
else:
res.append((record.id,-1))
#else:
# res.append((record.id,-1))
return dict(res)

_name = 'fleet.vehicle.log.contract'
Expand All @@ -756,13 +756,13 @@ def get_warning_date(self,cr,uid,ids,prop,unknow_none,context=None):
'purchaser_id' : fields.many2one('res.partner', 'Contractor',domain="['|',('customer','=',True),('employee','=',True)]",help='Person to which the contract is signed for'),
'ins_ref' : fields.char('Contract Reference', size=64),
'state' : fields.selection([('open', 'In Progress'), ('closed', 'Terminated')], 'Status', readonly=True, help='Choose wheter the contract is still valid or not'),
'reminder' : fields.boolean('Renewal Reminder', help="Warn the user a few days before the expiration date of this contract"),
#'reminder' : fields.boolean('Renewal Reminder', help="Warn the user a few days before the expiration date of this contract"),
'notes' : fields.text('Terms and Conditions', help='Write here all supplementary informations relative to this contract'),
'costs' : fields.one2many('fleet.vehicle.cost', 'parent_id', 'Costs covered'),


'odometer_id' : fields.many2one('fleet.vehicle.odometer', 'Odometer', required=False, help='Odometer measure of the vehicle at the moment of this log'),
'odometer' : fields.function(_get_odometer,fnct_inv=_set_odometer,type='char',string='Odometer',store=False,help='Odometer measure of the vehicle at the moment of this log'),
'odometer' : fields.function(_get_odometer,fnct_inv=_set_odometer,type='char',string='Value',store=False,help='Odometer measure of the vehicle at the moment of this log'),
'odometer_unit': fields.related('vehicle_id','odometer_unit',type="char",string="Unit",store=False, readonly=True),
}
_defaults = {
Expand All @@ -782,17 +782,7 @@ def contract_open(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state': 'open'})
return True

############################
############################
#Vehicle.log.contract.type class
############################
############################

class fleet_contract_type(osv.Model):
_name = 'fleet.contract.type'
_columns = {
'name': fields.char('Name', required=True, translate=True),
}
############################
############################
#Vehicle.log.contract.state class
Expand Down
7 changes: 2 additions & 5 deletions addons/fleet/fleet_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@
<group string="Contract details">
<field name="vehicle_id" on_change="on_change_vehicle(vehicle_id)"/>

<field name="cost_type" />
<field name="cost_type" required="1"/>
</group>
<group string="Odometer details">
<label for="odometer"/>
<div>
<field name="odometer" class="oe_inline"/>
<field name="odometer_unit" class="oe_inline"/>
Expand All @@ -369,7 +370,6 @@
<field name="date" />
<field name="start_date" on_change="on_change_start_date(start_date)"/>
<field name="expiration_date" />
<field name="reminder" />
</group>
<group>
<field name="insurer_id" />
Expand Down Expand Up @@ -435,9 +435,6 @@
contracts. Contracts can be of various type, from insurance
contracts to leasing contracts. Each contract is associated
to an existing vehicle and can also be associated to a user.
For each contract, you can ask for a reminder that will color
the contract in orange when the expiration date is near or in
red when the expiration date is passed.
</p>
</field>
</record>
Expand Down
1 change: 0 additions & 1 deletion addons/fleet/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ fleet_vehicle_access_right,fleet_vehicle_access_right,model_fleet_vehicle,,1,1,1
fleet_vehicle_log_fuel_access_right,fleet_vehicle_log_fuel_access_right,model_fleet_vehicle_log_fuel,,1,1,1,1
fleet_vehicle_log_services_access_right,fleet_vehicle_log_services_access_right,model_fleet_vehicle_log_services,,1,1,1,1
fleet_vehicle_log_contract_access_right,fleet_vehicle_log_contract_access_right,model_fleet_vehicle_log_contract,,1,1,1,1
fleet_contract_type_access_right,fleet_contract_type_access_right,model_fleet_contract_type,,1,1,1,1
fleet_service_type_access_right,fleet_service_type_access_right,model_fleet_service_type,,1,1,1,1

0 comments on commit 1697d61

Please sign in to comment.