Browse Source
[ADD] extension wizard + [CLEAN] Abstract class for all wizard related to action on the cooperative status
pull/19/head
[ADD] extension wizard + [CLEAN] Abstract class for all wizard related to action on the cooperative status
pull/19/head
Thibault Francois
8 years ago
7 changed files with 110 additions and 15 deletions
-
1beesdoo_shift/__openerp__.py
-
17beesdoo_shift/models/cooperative_status.py
-
9beesdoo_shift/views/cooperative_status.xml
-
3beesdoo_shift/wizard/__init__.py
-
37beesdoo_shift/wizard/extension.py
-
26beesdoo_shift/wizard/extension.xml
-
32beesdoo_shift/wizard/subscribe.py
@ -1,4 +1,5 @@ |
|||
import instanciate_planning |
|||
import batch_template |
|||
import assign_super_coop |
|||
import subscribe |
|||
import subscribe |
|||
import extension |
@ -0,0 +1,37 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from openerp import models, fields, api, _ |
|||
from openerp.exceptions import UserError |
|||
|
|||
class Subscribe(models.TransientModel): |
|||
_name = 'beesdoo.shift.extension' |
|||
_inherit = 'beesdoo.shift.action_mixin' |
|||
|
|||
def _get_default_extension_delay(self): |
|||
return int(self.env['ir.config_parameter'].get_param('default_extension_delay', 28)) |
|||
|
|||
|
|||
extension_start_date = fields.Date(string="Start date for the extension", default=fields.Date.today, readonly=True) |
|||
auto = fields.Boolean("Auto Extension", default=False) |
|||
extension_days = fields.Integer(default=_get_default_extension_delay) |
|||
|
|||
@api.multi |
|||
def auto_ext(self): |
|||
self = self._check() |
|||
status_id = self.env['cooperative.status'].search([('cooperator_id', '=', self.cooperator_id.id)]) |
|||
status_id.sudo().write({'extension_start_time': self.extension_start_date}) |
|||
|
|||
@api.multi |
|||
def extension(self): |
|||
self = self._check() #maybe a different group |
|||
grace_delay = int(self.env['ir.config_parameter'].get_param('default_grace_delay', 10)) |
|||
status_id = self.env['cooperative.status'].search([('cooperator_id', '=', self.cooperator_id.id)]) |
|||
if not status_id.extension_start_time: |
|||
raise UserError(_('You should not make a manual extension when the grace delay has not been triggered yet')) |
|||
extension_date = fields.Date.from_string(status_id.extension_start_time) |
|||
today = fields.Date.from_string(status_id.today) |
|||
today_delay = (today - extension_date).days - grace_delay |
|||
if today_delay < 0: |
|||
raise UserError(_('You should not start a manual extension during the grace delay')) |
|||
status_id.sudo().write({'time_extension': self.extension_days + today_delay}) |
|||
|
|||
#TO continue |
@ -0,0 +1,26 @@ |
|||
<odoo> |
|||
<record model="ir.ui.view" id="extension_coop_wizard_view_form"> |
|||
<field name="name">Extension Management</field> |
|||
<field name="model">beesdoo.shift.extension</field> |
|||
<field name="arch" type="xml"> |
|||
<form> |
|||
<field name="cooperator_id" invisible="1"/> |
|||
<field name="auto" invisible="1"/> |
|||
<group attrs="{'invisible': [('auto', '=', False)]}"> |
|||
<field name="extension_start_date" /> |
|||
</group> |
|||
<group attrs="{'invisible': [('auto', '=', True)]}"> |
|||
<field name="extension_days" /> |
|||
</group> |
|||
<footer> |
|||
<button type="object" name="extension" |
|||
string="Confirm" class="oe_highlight" attrs="{'invisible': [('auto', '=', True)]}" /> |
|||
<button type="object" name="auto_ext" |
|||
string="Confirm" class="oe_highlight" attrs="{'invisible': [('auto', '=', False)]}" /> |
|||
or |
|||
<button special="cancel" string="Cancel" /> |
|||
</footer> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue