- 'name' : fields.function(_vehicle_contract_name_get_fnc, type="text", string='Name', store=True),
-
- 'start_date' : fields.date('Contract Start Date', required=False, help='Date when the coverage of the contract begins'),
- 'expiration_date' : fields.date('Contract Expiration Date', required=False, help='Date when the coverage of the contract expirates (by default, one year after begin date)'),
- 'warning_date' : fields.function(get_warning_date,type='integer',string='Warning Date',store=False),
-
- 'insurer_id' :fields.many2one('res.partner', 'Supplier', domain="[('supplier','=',True)]"),
- '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'),('toclose','To Close'), ('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"),
- 'notes' : fields.text('Terms and Conditions', help='Write here all supplementary informations relative to this contract'),
- '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 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),
- 'cost_amount': fields.related('cost_id','amount',type="float",string="Amount",store=True, readonly=True),
- 'cost_generated': fields.float('Recurring Cost Amount',help="Costs paid at regular intervals, depending on the cost frequency. If the cost frequency is set to unique, the cost will be logged at the start date"),
- 'cost_frequency': fields.selection([('no','No'),('daily', 'Daily'),('weekly','Weekly'),('monthly','Monthly'),('yearly','Yearly')], 'Recurring Cost Frequency', help='Frequency of the recuring cost',required=True),
- 'generated_cost_ids' : fields.one2many('fleet.vehicle.cost', 'contract_id', 'Generated Costs',ondelete='cascade'),
- 'sum_cost' : fields.function(_get_sum_cost,type='float', string='Indicative Costs Total',readonly=True),
+ 'name': fields.function(_vehicle_contract_name_get_fnc, type="text", string='Name', store=True),
+ 'start_date': fields.date('Contract Start Date', help='Date when the coverage of the contract begins'),
+ 'expiration_date': fields.date('Contract Expiration Date', help='Date when the coverage of the contract expirates (by default, one year after begin date)'),
+ 'days_left': fields.function(get_days_left, type='integer', string='Warning Date'),
+ 'insurer_id' :fields.many2one('res.partner', 'Supplier'),
+ 'purchaser_id': fields.many2one('res.partner', 'Contractor', help='Person to which the contract is signed for'),
+ 'ins_ref': fields.char('Contract Reference', size=64),
+ 'state': fields.selection([('open', 'In Progress'), ('toclose','To Close'), ('closed', 'Terminated')], 'Status', readonly=True, help='Choose wheter the contract is still valid or not'),
+ 'notes': fields.text('Terms and Conditions', help='Write here all supplementary informations relative to this contract'),
+ 'cost_generated': fields.float('Recurring Cost Amount', help="Costs paid at regular intervals, depending on the cost frequency. If the cost frequency is set to unique, the cost will be logged at the start date"),
+ 'cost_frequency': fields.selection([('no','No'), ('daily', 'Daily'), ('weekly','Weekly'), ('monthly','Monthly'), ('yearly','Yearly')], 'Recurring Cost Frequency', help='Frequency of the recuring cost', required=True),
+ 'generated_cost_ids': fields.one2many('fleet.vehicle.cost', 'contract_id', 'Generated Costs', ondelete='cascade'),
+ 'sum_cost': fields.function(_get_sum_cost, type='float', string='Indicative Costs Total'),
+ 'cost_amount': fields.related('cost_id', 'amount', string='Amount', type='float', store=True), #we need to keep this field as a related with store=True because the graph view doesn't support (1) to address fields from inherited table and (2) fields that aren't stored in database