Commit a5f1a125 by François C.

Cron cloture automatique des services FTOP du jour

parent b9a6dc52
...@@ -660,7 +660,7 @@ msgstr "Remplacé" ...@@ -660,7 +660,7 @@ msgstr "Remplacé"
#: code:addons/coop_membership/models/shift_shift.py:81 #: code:addons/coop_membership/models/shift_shift.py:81
#, python-format #, python-format
msgid "Shift Cloture" msgid "Shift Cloture"
msgstr "Clôlturer le service" msgstr "Clôturer le service"
#. module: coop_membership #. module: coop_membership
#: model:ir.ui.view,arch_db:coop_membership.view_shift_form_inherit #: model:ir.ui.view,arch_db:coop_membership.view_shift_form_inherit
......
...@@ -2297,7 +2297,7 @@ msgstr "Service" ...@@ -2297,7 +2297,7 @@ msgstr "Service"
#: code:addons/coop_shift/model/shift_shift.py:434 #: code:addons/coop_shift/model/shift_shift.py:434
#, python-format #, python-format
msgid "Shift Cloture" msgid "Shift Cloture"
msgstr "Clôlturer le service" msgstr "Clôturer le service"
#. module: coop_shift #. module: coop_shift
#: model:ir.actions.act_window,name:coop_shift.action_res_partner_point_counter_view_ftop #: model:ir.actions.act_window,name:coop_shift.action_res_partner_point_counter_view_ftop
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
# always loaded # always loaded
'data': [ 'data': [
'data/ir_cron.xml', 'data/ir_cron.xml',
'ir_config_parameter_data.xml' 'data/ir_config_parameter_data.xml'
], ],
'installable': True, 'installable': True,
} }
...@@ -31,4 +31,17 @@ ...@@ -31,4 +31,17 @@
<field name="active" eval="False"/> <field name="active" eval="False"/>
<field name="priority">1</field> <field name="priority">1</field>
</record> </record>
<record forcecreate="True" id="cron_close_ftop_shifts" model="ir.cron">
<field name="name">Daily close FTOP shifts</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="True"/>
<field name="model" eval="'shift.shift'"/>
<field name="function" eval="'run_close_today_ftop_shifts'"/>
<field name="args" eval="'()'"/>
<field name="active" eval="False"/>
<field name="priority">1</field>
</record>
</odoo> </odoo>
\ No newline at end of file
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
from . import res_partner from . import res_partner
from . import shift_registration from . import shift_registration
from . import shift_counter_event from . import shift_counter_event
from . import shift_shift
# -*- coding: utf-8 -*-
from openerp import _, api, models, fields
import logging
_logger = logging.getLogger(__name__)
class ShiftShift(models.Model):
_inherit = 'shift.shift'
@api.model
def run_close_today_ftop_shifts(self):
"""Method called by cron task"""
sql = """
SELECT id
FROM shift_shift
WHERE TO_CHAR(date_begin, 'YYYY-MM-DD') = TO_CHAR(now(), 'YYYY-MM-DD')
AND active = true AND state = 'confirm'
"""
self.env.cr.execute(sql)
shift_ids = self.env.cr.fetchall()
if len(shift_ids) > 0:
for s in self.env['shift.shift'].search([('id', 'in', shift_ids)]):
s.button_makeupok()
s.button_done()
# _logger.info('Traité avec action makeupok et done sur shift ' + str(s.id))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment