diff --git a/beesdoo_shift/data/cron.xml b/beesdoo_shift/data/cron.xml index bc5a23d..b631015 100644 --- a/beesdoo_shift/data/cron.xml +++ b/beesdoo_shift/data/cron.xml @@ -6,18 +6,17 @@ hours -1 - + model._set_today() - Generate Next Planning 1 weeks -1 - + model._generate_next_planning() @@ -28,7 +27,7 @@ hours -1 - + model._cron_compute_counter_irregular() diff --git a/beesdoo_shift/models/cooperative_status.py b/beesdoo_shift/models/cooperative_status.py index 8f8737b..cac14ee 100644 --- a/beesdoo_shift/models/cooperative_status.py +++ b/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'