# -*- coding: utf-8 -*- ############################################################################## # # Cybrosys Technologies Pvt. Ltd. # Copyright (C) 2008-TODAY Cybrosys Technologies(). # Author: Nilmar Shereef() # 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.tools.translate import _ from openerp.osv import fields, osv class CarVehicle(osv.osv): _name = 'car.car' _inherit = ['mail.thread'] def get_task_count(self, cr, uid, ids, field_name, arg, context=None): if context is None: context = {} res = {} for vehicle in self.browse(cr, uid, ids, context=context): res[vehicle.id] = len(vehicle.task_ids) return res _columns = { 'active': fields.boolean(string='Active'), 'name': fields.integer(string='Vehicle Name', required=True), 'sequence': fields.integer(string='Sequence', help="Gives the sequence order when displaying a list of Projects."), 'label_tasks': fields.char(string='Use Tasks as', help="Gives label to tasks on project's kanban view."), 'worksheet': fields.one2many('car.workshop', 'vehicle_id', string="Task Activities"), 'type_ids': fields.many2many('worksheet.stages', 'car_workshop_type_rel', 'vehicle_id', 'type_id', 'Worksheet Stages', states={'close': [('readonly', True)], 'cancelled': [('readonly', True)]}), 'task_count': fields.function(get_task_count, type='integer', string="Tasks", ), 'task_ids': fields.one2many('car.workshop', 'vehicle_id'), 'color': fields.integer('Color Index'), 'partner_id': fields.many2one('res.partner', 'Customer'), 'state': fields.selection([('draft', 'Nuevo'), ('open', 'En progreso'), ('cancelled', 'Cancelado'), ('pending', 'Pendiente'), ('close', 'Cerrado')], string='Status', required=True, track_visibility='onchange', copy=False), 'date_start': fields.date(string='Start Date'), 'date': fields.date(string='Expiration Date', select=True, track_visibility='onchange'), 'use_tasks': fields.boolean(string='Tasks'), 'image_medium': fields.binary('Binary File'), } _defaults = { 'active': True, 'use_tasks': True, 'label_tasks': 'Trabajos', 'state': 'open', }