You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
924 B

  1. # coding: utf-8
  2. # Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
  3. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. import logging
  6. from openerp import api, fields, models
  7. _logger = logging.getLogger(__name__)
  8. class IrCron(models.Model):
  9. _inherit = 'ir.cron'
  10. inactivity_period_ids = fields.One2many(
  11. comodel_name='ir.cron.inactivity.period', string='Inactivity Periods',
  12. inverse_name='cron_id')
  13. @api.model
  14. def _callback(self, model_name, method_name, args, job_id):
  15. job = self.browse(job_id)
  16. if any(job.inactivity_period_ids._check_inactivity_period()):
  17. _logger.info(
  18. "Job %s skipped during inactivity period",
  19. job.name)
  20. return
  21. return super(IrCron, self)._callback(
  22. model_name, method_name, args, job_id)