Rémy Taymans
5 years ago
3 changed files with 85 additions and 78 deletions
-
1beesdoo_shift/models/__init__.py
-
78beesdoo_shift/models/cooperative_status.py
-
84beesdoo_shift/models/res_partner.py
@ -0,0 +1,84 @@ |
|||
from odoo import models, fields, api, _ |
|||
from odoo.exceptions import ValidationError, UserError |
|||
|
|||
from datetime import timedelta, datetime |
|||
import logging |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
""" |
|||
One2many relationship with CooperativeStatus should |
|||
be replaced by inheritance. |
|||
""" |
|||
_inherit = 'res.partner' |
|||
|
|||
worker_store = fields.Boolean(default=False) |
|||
is_worker = fields.Boolean(related="worker_store", string="Worker", readonly=False) |
|||
cooperative_status_ids = fields.One2many('cooperative.status', 'cooperator_id', readonly=True) |
|||
super = fields.Boolean(related='cooperative_status_ids.super', string="Super Cooperative", readonly=True, store=True) |
|||
info_session = fields.Boolean(related='cooperative_status_ids.info_session', string='Information Session ?', readonly=True, store=True) |
|||
info_session_date = fields.Date(related='cooperative_status_ids.info_session_date', string='Information Session Date', readonly=True, store=True) |
|||
working_mode = fields.Selection(related='cooperative_status_ids.working_mode', readonly=True, store=True) |
|||
exempt_reason_id = fields.Many2one(related='cooperative_status_ids.exempt_reason_id', readonly=True, store=True) |
|||
state = fields.Selection(related='cooperative_status_ids.status', readonly=True, store=True) |
|||
extension_start_time = fields.Date(related='cooperative_status_ids.extension_start_time', string="Extension Start Day", readonly=True, store=True) |
|||
subscribed_shift_ids = fields.Many2many('beesdoo.shift.template') |
|||
|
|||
@api.multi |
|||
def coop_subscribe(self): |
|||
return { |
|||
'name': _('Subscribe Cooperator'), |
|||
'type': 'ir.actions.act_window', |
|||
'view_type': 'form', |
|||
'view_mode': 'form', |
|||
'res_model': 'beesdoo.shift.subscribe', |
|||
'target': 'new', |
|||
} |
|||
|
|||
@api.multi |
|||
def coop_unsubscribe(self): |
|||
res = self.coop_subscribe() |
|||
res['context'] = {'default_unsubscribed': True} |
|||
return res |
|||
|
|||
@api.multi |
|||
def manual_extension(self): |
|||
return { |
|||
'name': _('Manual Extension'), |
|||
'type': 'ir.actions.act_window', |
|||
'view_type': 'form', |
|||
'view_mode': 'form', |
|||
'res_model': 'beesdoo.shift.extension', |
|||
'target': 'new', |
|||
} |
|||
|
|||
@api.multi |
|||
def auto_extension(self): |
|||
res = self.manual_extension() |
|||
res['context'] = {'default_auto': True} |
|||
res['name'] = _('Trigger Grace Delay') |
|||
return res |
|||
|
|||
@api.multi |
|||
def register_holiday(self): |
|||
return { |
|||
'name': _('Register Holiday'), |
|||
'type': 'ir.actions.act_window', |
|||
'view_type': 'form', |
|||
'view_mode': 'form', |
|||
'res_model': 'beesdoo.shift.holiday', |
|||
'target': 'new', |
|||
} |
|||
|
|||
@api.multi |
|||
def temporary_exempt(self): |
|||
return { |
|||
'name': _('Temporary Exemption'), |
|||
'type': 'ir.actions.act_window', |
|||
'view_type': 'form', |
|||
'view_mode': 'form', |
|||
'res_model': 'beesdoo.shift.temporary_exemption', |
|||
'target': 'new', |
|||
} |
|||
|
|||
#TODO access right + vue on res.partner |
Write
Preview
Loading…
Cancel
Save
Reference in new issue