config.py 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 import fields, models, api
  24. from openerp.tools.translate import _
  25. class WorkshopSetting(models.Model):
  26. _name = "workshop.config.setting"
  27. invoice_journal_type = fields.Many2one('account.journal', string="Car Workshop Journal")
  28. @api.multi
  29. def execute(self):
  30. return self.env['ir.values'].sudo().set_default(
  31. 'workshop.config.setting', 'invoice_journal_type', self.invoice_journal_type.id)
  32. def cancel(self, cr, uid, ids, context=None):
  33. act_window = self.pool['ir.actions.act_window']
  34. action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)])
  35. if action_ids:
  36. return act_window.read(cr, uid, action_ids[0], [], context=context)
  37. return {}
  38. class WorksheetTags(models.Model):
  39. _name = "worksheet.tags"
  40. _description = "Tags of vehicles's tasks, issues..."
  41. name = fields.Char(string='Name', required=True)
  42. color = fields.Integer(string='Color Index')
  43. _sql_constraints = [
  44. ('name_uniq', 'unique (name)', "Tag name already exists !"),
  45. ]
  46. class WorksheetStages(models.Model):
  47. _name = 'worksheet.stages'
  48. _description = 'worksheet Stage'
  49. _order = 'sequence'
  50. name = fields.Char(string='Stage Name', required=True)
  51. description = fields.Text(string='Description', translate=True)
  52. sequence = fields.Integer(string='Sequence')
  53. vehicle_ids = fields.Many2many('car.car', 'worksheet_type_rel', 'type_id', 'vehicle_id', string='Vechicles')
  54. fold = fields.Boolean('Folded in Tasks Pipeline', help='This stage is folded in the kanban view when'
  55. 'there are no records in that stage to display.')
  56. def _get_default_vehicle_ids(self, cr, uid, ctx=None):
  57. if ctx is None:
  58. ctx = {}
  59. default_vehicle_id = ctx.get('default_vehicle_id')
  60. return [default_vehicle_id] if default_vehicle_id else None
  61. _defaults = {
  62. 'sequence': 1,
  63. 'vehicle_ids': _get_default_vehicle_ids,
  64. }
  65. _order = 'sequence'
  66. class Services(models.Model):
  67. _inherit = 'product.template'
  68. type = fields.Selection([('consu', _('Consumable')), ('service', _('Service')),
  69. ('product', _('Stockable Product'))],
  70. string='Product Type', required=True,
  71. help="A consumable is a product for which you don't manage stock,"
  72. " a service is a non-material product provided by a company or an individual.")
  73. _defaults = {
  74. 'type': 'service',
  75. }