You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
3.1 KiB

  1. from odoo import models, fields, api, _
  2. from odoo.exceptions import ValidationError, UserError
  3. from datetime import timedelta, datetime
  4. import logging
  5. class ResPartner(models.Model):
  6. """
  7. One2many relationship with CooperativeStatus should
  8. be replaced by inheritance.
  9. """
  10. _inherit = 'res.partner'
  11. worker_store = fields.Boolean(default=False)
  12. is_worker = fields.Boolean(related="worker_store", string="Worker", readonly=False)
  13. cooperative_status_ids = fields.One2many('cooperative.status', 'cooperator_id', readonly=True)
  14. super = fields.Boolean(related='cooperative_status_ids.super', string="Super Cooperative", readonly=True, store=True)
  15. info_session = fields.Boolean(related='cooperative_status_ids.info_session', string='Information Session ?', readonly=True, store=True)
  16. info_session_date = fields.Date(related='cooperative_status_ids.info_session_date', string='Information Session Date', readonly=True, store=True)
  17. working_mode = fields.Selection(related='cooperative_status_ids.working_mode', readonly=True, store=True)
  18. exempt_reason_id = fields.Many2one(related='cooperative_status_ids.exempt_reason_id', readonly=True, store=True)
  19. state = fields.Selection(related='cooperative_status_ids.status', readonly=True, store=True)
  20. extension_start_time = fields.Date(related='cooperative_status_ids.extension_start_time', string="Extension Start Day", readonly=True, store=True)
  21. subscribed_shift_ids = fields.Many2many('beesdoo.shift.template')
  22. @api.multi
  23. def coop_subscribe(self):
  24. return {
  25. 'name': _('Subscribe Cooperator'),
  26. 'type': 'ir.actions.act_window',
  27. 'view_type': 'form',
  28. 'view_mode': 'form',
  29. 'res_model': 'beesdoo.shift.subscribe',
  30. 'target': 'new',
  31. }
  32. @api.multi
  33. def coop_unsubscribe(self):
  34. res = self.coop_subscribe()
  35. res['context'] = {'default_unsubscribed': True}
  36. return res
  37. @api.multi
  38. def manual_extension(self):
  39. return {
  40. 'name': _('Manual Extension'),
  41. 'type': 'ir.actions.act_window',
  42. 'view_type': 'form',
  43. 'view_mode': 'form',
  44. 'res_model': 'beesdoo.shift.extension',
  45. 'target': 'new',
  46. }
  47. @api.multi
  48. def auto_extension(self):
  49. res = self.manual_extension()
  50. res['context'] = {'default_auto': True}
  51. res['name'] = _('Trigger Grace Delay')
  52. return res
  53. @api.multi
  54. def register_holiday(self):
  55. return {
  56. 'name': _('Register Holiday'),
  57. 'type': 'ir.actions.act_window',
  58. 'view_type': 'form',
  59. 'view_mode': 'form',
  60. 'res_model': 'beesdoo.shift.holiday',
  61. 'target': 'new',
  62. }
  63. @api.multi
  64. def temporary_exempt(self):
  65. return {
  66. 'name': _('Temporary Exemption'),
  67. 'type': 'ir.actions.act_window',
  68. 'view_type': 'form',
  69. 'view_mode': 'form',
  70. 'res_model': 'beesdoo.shift.temporary_exemption',
  71. 'target': 'new',
  72. }
  73. #TODO access right + vue on res.partner