Browse Source

[FIX] Module beesdoo_shift : fixed cron jobs definition to fit version 12.0 requirements.

pull/105/head
Elouan 5 years ago
parent
commit
eba5c74bcc
  1. 7
      beesdoo_shift/data/cron.xml
  2. 15
      beesdoo_shift/models/cooperative_status.py

7
beesdoo_shift/data/cron.xml

@ -6,18 +6,17 @@
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model_id" ref="cooperative.status">
<field name="model_id" ref="model_cooperative_status" />
<field name="code">model._set_today()</field>
</record>
<record id="ir_cron_generate_next_planning" model="ir.cron">
<field name="name">Generate Next Planning</field>
<field name="interval_number">1</field>
<field name="interval_type">weeks</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="model_id" ref="beesdoo.shift.planning">
<field name="model_id" ref="model_beesdoo_shift_planning" />
<field name="code">model._generate_next_planning()</field>
<field name="active" eval="False" />
</record>
@ -28,7 +27,7 @@
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="doall" eval="True" />
<field name="model_id" ref="cooperative.status">
<field name="model_id" ref="model_cooperative_status" />
<field name="code">model._cron_compute_counter_irregular()</field>
<field name="active" eval="False" />
</record>

15
beesdoo_shift/models/cooperative_status.py

@ -3,7 +3,6 @@ from odoo.exceptions import ValidationError
from datetime import timedelta, datetime
import logging
from odoo.osv.fields import related
_logger = logging.getLogger(__name__)
PERIOD = 28 # TODO: use system parameter
@ -363,7 +362,7 @@ class CooperativeStatus(models.Model):
def clear_history(self):
self.ensure_one()
self.history_ids.unlink()
@api.model
def _cron_compute_counter_irregular(self, today=False):
today = today or fields.Date.today()
@ -393,27 +392,27 @@ class CooperativeStatus(models.Model):
else:
status.sr -= 2
journal.line_ids |= status
class ShiftCronJournal(models.Model):
_name = 'beesdoo.shift.journal'
_order = 'date desc'
_rec_name = 'date'
date = fields.Date()
line_ids = fields.Many2many('cooperative.status')
_sql_constraints = [
('one_entry_per_day', 'unique (date)', _('You can only create one journal per day')),
]
@api.multi
def run(self):
self.ensure_one()
if not self.user_has_groups('beesdoo_shift.group_cooperative_admin'):
raise ValidationError(_("You don't have the access to perform this action"))
self.sudo().env['cooperative.status']._cron_compute_counter_irregular(today=self.date)
class ResPartner(models.Model):
_inherit = 'res.partner'

Loading…
Cancel
Save