[ADD]add renew contract
bzr revid: csn@openerp.com-20121023130152-51hd311rn0prj3oq
This commit is contained in:
parent
23d286ef52
commit
24635aae19
|
@ -916,7 +916,8 @@ class fleet_vehicle_log_contract(osv.Model):
|
|||
nextyear=curdate+oneyear#int(strdate[:4])+1
|
||||
return str(nextyear)#+strdate[4:]
|
||||
|
||||
def on_change_start_date(self, cr, uid, ids, strdate, context=None):
|
||||
def on_change_start_date(self, cr, uid, ids, strdate, enddate, context=None):
|
||||
|
||||
if (strdate):
|
||||
|
||||
return {'value' : {'expiration_date' : self.compute_next_year_date(strdate),}}
|
||||
|
@ -951,7 +952,7 @@ class fleet_vehicle_log_contract(osv.Model):
|
|||
|
||||
def act_renew_contract(self,cr,uid,ids,context=None):
|
||||
contracts = self.browse(cr,uid,ids,context=context)
|
||||
res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid ,'fleet','act_renew_contract_wizard', context)
|
||||
res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid ,'fleet','act_renew_contract', context)
|
||||
for element in contracts:
|
||||
temp = []
|
||||
temp.append(('default_vehicle_id',element.vehicle_id.id))
|
||||
|
@ -965,24 +966,29 @@ class fleet_vehicle_log_contract(osv.Model):
|
|||
cost_temp.append(costs.id)
|
||||
temp.append(('default_cost_ids',cost_temp))
|
||||
temp.append(('default_date',time.strftime('%Y-%m-%d')))
|
||||
temp.append(('default_start_date',element.expiration_date))
|
||||
temp.append(('default_start_date',str(self.str_to_date(element.expiration_date)+datetime.timedelta(days=1))))
|
||||
temp.append(('default_purchaser_id',element.purchaser_id.id))
|
||||
temp.append(('default_ins_ref',element.ins_ref))
|
||||
temp.append(('default_state','open'))
|
||||
temp.append(('default_notes',element.notes))
|
||||
temp.append(('default_cost_frequency',element.cost_frequency))
|
||||
generated_cost = []
|
||||
for gen_cost in element.generated_cost_ids:
|
||||
generated_cost.append(gen_cost.id)
|
||||
temp.append(('default_generated_cost_ids',generated_cost))
|
||||
|
||||
#compute end date
|
||||
startdate = self.str_to_date(element.start_date)
|
||||
enddate = self.str_to_date(element.expiration_date)
|
||||
diffdate = (enddate-startdate)
|
||||
newenddate = enddate+diffdate
|
||||
temp.append(('default_expiration_date',str(newenddate)))
|
||||
|
||||
res['context'] = dict(temp)
|
||||
#res['context']['default_vehicle_id'] = element.vehicle_id.id
|
||||
#res['context'] = {
|
||||
# 'default_vehicle_id': element.vehicle_id.id,
|
||||
# 'default_cost_type': element.cost_type.id,
|
||||
# 'default_amount': element.amount,
|
||||
# 'default_odometer': element.odometer,
|
||||
# 'default_insurer_id': element.insurer_id.id,
|
||||
#}
|
||||
#res['domain']=[('vehicle_id','=', ids[0])]
|
||||
|
||||
return res
|
||||
#return None
|
||||
|
||||
|
||||
|
||||
_name = 'fleet.vehicle.log.contract'
|
||||
_order='state,expiration_date'
|
||||
|
@ -1014,13 +1020,14 @@ class fleet_vehicle_log_contract(osv.Model):
|
|||
'date' : time.strftime('%Y-%m-%d'),
|
||||
'start_date' : time.strftime('%Y-%m-%d'),
|
||||
'state':'open',
|
||||
#'expiration_date' : self.compute_next_year_date(time.strftime('%Y-%m-%d')),
|
||||
'expiration_date' : lambda self,cr,uid,ctx: self.compute_next_year_date(time.strftime('%Y-%m-%d')),
|
||||
|
||||
}
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
default = default or {}
|
||||
current_object = self.browse(cr,uid,id,context)
|
||||
default['date'] = time.strftime('%Y-%m-%d')
|
||||
default['start_date'] = time.strftime('%Y-%m-%d')
|
||||
default['expiration_date'] = self.compute_next_year_date(time.strftime('%Y-%m-%d'))
|
||||
#default['name'] = current_object.name
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
<p class="oe_view_nocontent_create">
|
||||
Click to create a new model.
|
||||
</p><p>
|
||||
Here you can add the different model for a
|
||||
particular brand of vehicle. Like Audi A3,
|
||||
Specify the different model for a particular
|
||||
brand of vehicle. For example Audi A3,
|
||||
Audi A4, ...
|
||||
</p>
|
||||
</field>
|
||||
|
@ -147,7 +147,6 @@
|
|||
<p class="oe_view_nocontent_create">
|
||||
Click to create a new state.
|
||||
</p><p>
|
||||
Here you can create and organize the state for a vehicle.
|
||||
A state can help you knowing in what condition your
|
||||
vehicle is. In reparation, Sold, Active, ...
|
||||
</p>
|
||||
|
@ -258,6 +257,7 @@
|
|||
<field name="tag_ids"/>
|
||||
<field name="location"/>
|
||||
<field name="state" />
|
||||
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -436,7 +436,7 @@
|
|||
<group col="2">
|
||||
<group>
|
||||
<field name="date" string="Invoice Date"/>
|
||||
<field name="start_date" on_change="on_change_start_date(start_date)"/>
|
||||
<field name="start_date"/>
|
||||
<field name="expiration_date" />
|
||||
</group>
|
||||
<group>
|
||||
|
|
Loading…
Reference in New Issue