Browse Source

[MIG] b_shift : datetimes aren't strings anymore

pull/143/head
Elouan Le Bars 5 years ago
parent
commit
402c9181f5
  1. 25
      beesdoo_shift/data/cron.xml
  2. 3
      beesdoo_shift/models/task.py
  3. 4
      beesdoo_shift/views/attendance_sheet.xml

25
beesdoo_shift/data/cron.xml

@ -49,24 +49,25 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="nextcall" eval="datetime.combine(datetime.now(), time(hour=00, minute=00, second=10))">
<field name="nextcall" eval="datetime.now().replace(hour=00, minute=00, second=10)" />
<field name="model_id" ref="model_beesdoo_shift_sheet" />
<field name="code">model._cron_non_validated_sheets()</field>
<field name="active" eval="False" />
</record>
<record id="ir_cron_send_weekly_emails" model="ir.cron">
<field name="name">Send weekly shift summary</field>
<field name="interval_number">7</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="True" />
<field name="nextcall"
eval="datetime.utcnow() + timedelta((6-datetime.utcnow().weekday()) % 7"
/>
<field name="model_id" ref="model_beesdoo_shift_shift" />
<field name="code">_cron_send_weekly_emails()</field>
<field name="active" eval="False" />
<field name="name">Send weekly shift summary</field>
<field name="interval_number">7</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="True" />
<field name="nextcall"
eval="datetime.now() + timedelta((6 - datetime.now().weekday()) % 7)"
/>
<field name="model_id" ref="model_beesdoo_shift_shift" />
<field name="code">_cron_send_weekly_emails()</field>
<field name="active" eval="False" />
</record>
</data>
</odoo>

3
beesdoo_shift/models/task.py

@ -80,8 +80,7 @@ class Task(models.Model):
@api.constrains("state")
def _lock_future_task(self):
start_time_dt = fields.Datetime.from_string(self.start_time)
if datetime.now() < start_time_dt:
if datetime.now() < self.start_time:
if self.state in ["done", "absent_2", "absent_1", "absent_0"]:
raise UserError(_(
"Shift state of a future shift "

4
beesdoo_shift/views/attendance_sheet.xml

@ -231,8 +231,8 @@
name="Daily attendance sheets"
res_model="beesdoo.shift.sheet"
view_mode="tree,form"
domain="[('end_time','&gt;', datetime.combine(datetime.now(), time(hour=00, minute=00, second=10))),
('start_time','&lt;', datetime.combine(datetime.now(), time(hour=23, minute=59, second=59)))]"
domain="[('end_time','&gt;', datetime.now().replace(hour=00, minute=00, second=10)),
('start_time','&lt;', datetime.now().replace(hour=23, minute=59, second=59))]"
/>
<!-- Top menu item -->

Loading…
Cancel
Save