Thibault Francois
7 years ago
committed by
Elouan
8 changed files with 90 additions and 8 deletions
-
1beesdoo_shift/__openerp__.py
-
28beesdoo_shift/models/cooperative_status.py
-
5beesdoo_shift/models/planning.py
-
2beesdoo_shift/models/task.py
-
14beesdoo_shift/views/cooperative_status.xml
-
1beesdoo_shift/wizard/__init__.py
-
24beesdoo_shift/wizard/temporary_exemption.py
-
21beesdoo_shift/wizard/temporary_exemption.xml
@ -0,0 +1,24 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from openerp import models, fields, api, _ |
||||
|
from openerp.exceptions import ValidationError |
||||
|
|
||||
|
class TemporaryExemption(models.TransientModel): |
||||
|
_name = 'beesdoo.shift.temporary_exemption' |
||||
|
_inherit = 'beesdoo.shift.action_mixin' |
||||
|
|
||||
|
temporary_exempt_reason_id = fields.Many2one('cooperative.exempt.reason', 'Exempt Reason', required=True) |
||||
|
temporary_exempt_start_date = fields.Date(default=fields.Date.today, required=True) |
||||
|
temporary_exempt_end_date = fields.Date(required=True) |
||||
|
|
||||
|
@api.multi |
||||
|
def exempt(self): |
||||
|
self = self._check() #maybe a different group |
||||
|
status_id = self.env['cooperative.status'].search([('cooperator_id', '=', self.cooperator_id.id)]) |
||||
|
if status_id.temporary_exempt_end_date >= status_id.today: |
||||
|
raise ValidationError(_("You cannot encode new temporary exemptuon since the previous one are not over yet")) |
||||
|
status_id.sudo().write({ |
||||
|
'temporary_exempt_start_date': self.temporary_exempt_start_date, |
||||
|
'temporary_exempt_end_date': self.temporary_exempt_end_date, |
||||
|
'temporary_exempt_reason_id': self.temporary_exempt_reason_id.id, |
||||
|
}) |
||||
|
self.env['beesdoo.shift.shift'].sudo().unsubscribe_from_today([self.cooperator_id.id], today=self.temporary_exempt_start_date, end_date=self.temporary_exempt_end_date) |
@ -0,0 +1,21 @@ |
|||||
|
<odoo> |
||||
|
<record model="ir.ui.view" id="holiday_coop_wizard_view_form"> |
||||
|
<field name="name">Temporary Exemption</field> |
||||
|
<field name="model">beesdoo.shift.temporary_exemption</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form> |
||||
|
<field name="cooperator_id" invisible="1"/> |
||||
|
<group> |
||||
|
<field name="temporary_exempt_reason_id" /> |
||||
|
<field name="temporary_exempt_start_date" /> |
||||
|
<field name="temporary_exempt_end_date" /> |
||||
|
</group> |
||||
|
<footer> |
||||
|
<button type="object" name="exempt" |
||||
|
string="Confirm" class="oe_highlight" /> |
||||
|
<button special="cancel" string="Cancel" /> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue