Browse Source

[ADD] beesdoo_shift: add compensation shift option in task

pull/105/head
nicolasjamoulle 6 years ago
committed by Elouan
parent
commit
4452e31005
  1. 13
      beesdoo_shift/models/task.py
  2. 15
      beesdoo_shift/views/task.xml

13
beesdoo_shift/models/task.py

@ -39,11 +39,22 @@ class Task(models.Model):
stage_id = fields.Many2one('beesdoo.shift.stage', required=True, track_visibility='onchange', default=lambda self: self.env.ref('beesdoo_shift.open')) stage_id = fields.Many2one('beesdoo.shift.stage', required=True, track_visibility='onchange', default=lambda self: self.env.ref('beesdoo_shift.open'))
super_coop_id = fields.Many2one('res.users', string="Super Cooperative", domain=[('partner_id.super', '=', True)], track_visibility='onchange') super_coop_id = fields.Many2one('res.users', string="Super Cooperative", domain=[('partner_id.super', '=', True)], track_visibility='onchange')
color = fields.Integer(related="stage_id.color", readonly=True) color = fields.Integer(related="stage_id.color", readonly=True)
is_regular = fields.Boolean(default=False)
is_regular = fields.Boolean(default=False, string="Regular shift")
is_compensation = fields.Boolean(default=False, string="Compensation shift")
replaced_id = fields.Many2one('res.partner', track_visibility='onchange', domain=[('eater', '=', 'worker_eater')]) replaced_id = fields.Many2one('res.partner', track_visibility='onchange', domain=[('eater', '=', 'worker_eater')])
revert_info = fields.Text(copy=False) revert_info = fields.Text(copy=False)
working_mode = fields.Selection(related='worker_id.working_mode') working_mode = fields.Selection(related='worker_id.working_mode')
@api.onchange('is_regular')
def _onchange_shift_is_regular(self):
for task in self:
task.is_compensation = not task.is_regular
@api.onchange('is_compensation')
def _onchange_shift_is_compensation(self):
for task in self:
task.is_regular = not task.is_compensation
def message_auto_subscribe(self, updated_fields, values=None): def message_auto_subscribe(self, updated_fields, values=None):
self._add_follower(values) self._add_follower(values)
return super(Task, self).message_auto_subscribe(updated_fields, values=values) return super(Task, self).message_auto_subscribe(updated_fields, values=values)

15
beesdoo_shift/views/task.xml

@ -102,9 +102,16 @@
<field name="replaced_id" <field name="replaced_id"
options="{'no_create': True, 'no_open': True}" options="{'no_create': True, 'no_open': True}"
domain="[('working_mode', '=', 'regular')]" domain="[('working_mode', '=', 'regular')]"
attrs="{'invisible': [('is_regular', '!=', True)]}"/>
<field name="is_regular" attrs="{'invisible': [('working_mode', '=', 'irregular')]}"/>
<field name="working_mode" invisible="1" />
attrs="{'invisible': [('is_regular', '!=', True), ('is_compensation', '!=', True)]}"/>
<group>
<field name="is_regular"
attrs="{'invisible': [('working_mode', '=', 'irregular')], 'required':[('is_compensation', '=', False)]}">
Regular shift
</field>
<field name="is_compensation"
attrs="{'invisible': [('working_mode', '=', 'irregular')], 'required':[('is_regular', '=', False)]}"/>
<field name="working_mode" invisible="1"/>
</group>
</group> </group>
<group> <group>
<field name="start_time" /> <field name="start_time" />
@ -179,7 +186,7 @@
Super Coop: Super Coop:
<field name="super_coop_id" /> <field name="super_coop_id" />
</div> </div>
<div t-if="record.is_regular.raw_value" >
<div t-if="record.is_regular.raw_value">
Regular Shift Regular Shift
</div> </div>

Loading…
Cancel
Save