dashboard.py 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Cybrosys Technologies Pvt. Ltd.
  5. # Copyright (C) 2008-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
  6. # Author: Nilmar Shereef(<http://www.cybrosys.com>)
  7. # you can modify it under the terms of the GNU LESSER
  8. # GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
  9. #
  10. # It is forbidden to publish, distribute, sublicense, or sell copies
  11. # of the Software or modified copies of the Software.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
  17. #
  18. # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
  19. # GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
  20. # If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. ##############################################################################
  23. from openerp.tools.translate import _
  24. from openerp.osv import fields, osv
  25. class CarVehicle(osv.osv):
  26. _name = 'car.car'
  27. _inherit = ['mail.thread']
  28. def get_task_count(self, cr, uid, ids, field_name, arg, context=None):
  29. if context is None:
  30. context = {}
  31. res = {}
  32. for vehicle in self.browse(cr, uid, ids, context=context):
  33. res[vehicle.id] = len(vehicle.task_ids)
  34. return res
  35. _columns = {
  36. 'active': fields.boolean(string='Active'),
  37. 'name': fields.integer(string='Vehicle Name', required=True),
  38. 'sequence': fields.integer(string='Sequence', help="Gives the sequence order when displaying a list of Projects."),
  39. 'label_tasks': fields.char(string='Use Tasks as', help="Gives label to tasks on project's kanban view."),
  40. 'worksheet': fields.one2many('car.workshop', 'vehicle_id', string="Task Activities"),
  41. 'type_ids': fields.many2many('worksheet.stages', 'car_workshop_type_rel', 'vehicle_id',
  42. 'type_id', 'Worksheet Stages',
  43. states={'close': [('readonly', True)], 'cancelled': [('readonly', True)]}),
  44. 'task_count': fields.function(get_task_count, type='integer', string="Tasks", ),
  45. 'task_ids': fields.one2many('car.workshop', 'vehicle_id'),
  46. 'color': fields.integer('Color Index'),
  47. 'partner_id': fields.many2one('res.partner', 'Customer'),
  48. 'state': fields.selection([('draft', 'Nuevo'),
  49. ('open', 'En progreso'),
  50. ('cancelled', 'Cancelado'),
  51. ('pending', 'Pendiente'),
  52. ('close', 'Cerrado')],
  53. string='Status', required=True, track_visibility='onchange', copy=False),
  54. 'date_start': fields.date(string='Start Date'),
  55. 'date': fields.date(string='Expiration Date', select=True, track_visibility='onchange'),
  56. 'use_tasks': fields.boolean(string='Tasks'),
  57. 'image_medium': fields.binary('Binary File'),
  58. }
  59. _defaults = {
  60. 'active': True,
  61. 'use_tasks': True,
  62. 'label_tasks': 'Trabajos',
  63. 'state': 'open',
  64. }