# -*- coding: utf-8 -*- ############################################################################## # # Cybrosys Technologies Pvt. Ltd. # Copyright (C) 2009-TODAY Cybrosys Technologies(). # # you can modify it under the terms of the GNU LESSER # GENERAL PUBLIC LICENSE (LGPL v3), Version 3. # # It is forbidden to publish, distribute, sublicense, or sell copies # of the Software or modified copies of the Software. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. # # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE # GENERAL PUBLIC LICENSE (LGPL v3) along with this program. # If not, see . # ############################################################################## from openerp import models, fields, api class CabManagement(models.Model): _name = 'cab.management' name = fields.Char(string="Cab Name", required=True) cab_image = fields.Binary(string='Image', store=True, attachment=True) licence_plate = fields.Char(string="Licence Plate", required=True) activity_period_from = fields.Date(string="Activity Period") activity_period_to = fields.Date(string="To") driver_plot = fields.Char(string="Driver Ploted") cab_value = fields.Float(string="Cab Value") cab_model = fields.Char(string="Cab Model") cab_color = fields.Char(string="Cab Color") aq_date = fields.Date(string="Aquisition Date") chas_no = fields.Char(string="Chasis No") odo_reading = fields.Float(string="Odometre Reading") seating_capacity = fields.Integer(string="Seating Capacity", required=True) fuel_type = fields.Char(string="Fuel Type") related_log_details = fields.One2many('cab.log', string="Log Details", compute="auto_fetch_log_details") total_log_details = fields.One2many('cab.maintanence', string='Total Expenses', compute="auto_fetch_total_details") location_log_details = fields.One2many('cab.log', string="Location", compute="auto_fetch_location_details") @api.onchange('activity_period_from', 'activity_period_to') def auto_fetch_log_details(self): data = self.env['cab.log'].search([("cab_log_date", ">=", self.activity_period_from), ("cab_log_date", "<=", self.activity_period_to)]) self.related_log_details = data @api.onchange('activity_period_from', 'activity_period_to') def auto_fetch_total_details(self): data = self.env['cab.maintanence'].search([("cab_log_date", ">=", self.activity_period_from), ("cab_log_date", "<=", self.activity_period_to)]) self.total_log_details = data @api.onchange('activity_period_from', 'activity_period_to') def auto_fetch_location_details(self): data = self.env['cab.log'].search([("cab_log_date", ">=", self.activity_period_from), ("cab_log_date", "<=", self.activity_period_to)]) self.location_log_details = data