Commit 38988e61 by François C.

Correctifs usage des status 'forcés' et délai (réinit. rattrapages dûs)

parent 56244ea4
<?xml version="1.0"?> <?xml version="1.0"?>
<odoo noupdate="0"> <odoo noupdate="0">
<record id="makeups_to_do_if_missed_id" model="ir.config_parameter">
<field name="key">lacagette_membership.makeups_to_do_on_shift_missed</field>
<field name="value">2</field>
</record>
<record id="points_limit_to_get_suspended" model="ir.config_parameter"> <record id="points_limit_to_get_suspended" model="ir.config_parameter">
<field name="key">lacagette_membership.points_limit_to_get_suspended</field> <field name="key">lacagette_membership.points_limit_to_get_suspended</field>
<field name="value">-2</field> <field name="value">-2</field>
...@@ -12,7 +9,7 @@ ...@@ -12,7 +9,7 @@
<field name="key">lacagette_membership.points_limit_to_get_unsubscribed</field> <field name="key">lacagette_membership.points_limit_to_get_unsubscribed</field>
<field name="value">-3</field> <field name="value">-3</field>
</record> </record>
<record id="makeups_to_do_if_missed_id" model="ir.config_parameter"> <record id="absence_status" model="ir.config_parameter">
<field name="key">lacagette_membership.absence_status</field> <field name="key">lacagette_membership.absence_status</field>
<field name="value">excused</field> <field name="value">excused</field>
</record> </record>
......
...@@ -26,6 +26,8 @@ class ResPartner(models.Model): ...@@ -26,6 +26,8 @@ class ResPartner(models.Model):
def run_process_target_status(self): def run_process_target_status(self):
"""Method called by cron task""" """Method called by cron task"""
# final_ftop_point, target_status # final_ftop_point, target_status
conf = self.env['ir.config_parameter']
absence_status = conf.get_param("lacagette_membership.absence_status")
for p in self.env['res.partner']\ for p in self.env['res.partner']\
.search([('target_status', '!=', "")]): .search([('target_status', '!=', "")]):
...@@ -33,6 +35,7 @@ class ResPartner(models.Model): ...@@ -33,6 +35,7 @@ class ResPartner(models.Model):
if p.final_ftop_point < 0: if p.final_ftop_point < 0:
new_values['cooperative_state'] = p.target_status new_values['cooperative_state'] = p.target_status
if new_values['cooperative_state'] == "unsubscribed": if new_values['cooperative_state'] == "unsubscribed":
new_values['makeups_to_do'] = 2 if absence_status == 'absent' else 1
""" """
unlink model: "shift.template.registration" unlink model: "shift.template.registration"
to delete all future shifts linked to this coop. to delete all future shifts linked to this coop.
...@@ -40,6 +43,7 @@ class ResPartner(models.Model): ...@@ -40,6 +43,7 @@ class ResPartner(models.Model):
for streg in self.env['shift.template.registration']\ for streg in self.env['shift.template.registration']\
.search([('partner_id', '=', p.id)]): .search([('partner_id', '=', p.id)]):
streg.unlink() streg.unlink()
p.update(new_values) p.update(new_values)
#@api.onchange('cooperativestate') : could be used only if it is called from client #@api.onchange('cooperativestate') : could be used only if it is called from client
...@@ -50,7 +54,7 @@ class ResPartner(models.Model): ...@@ -50,7 +54,7 @@ class ResPartner(models.Model):
SELECT s.id SELECT s.id
FROM shift_extension as s FROM shift_extension as s
WHERE s.date_stop > now() WHERE s.date_stop > now()
AND partner_id IN (SELECT id FROM res_partner WHERE cooperative_state='up_to_date') AND partner_id IN (SELECT id FROM res_partner WHERE cooperative_state in ('up_to_date', 'unsubscribed')
""" """
self.env.cr.execute(sql) self.env.cr.execute(sql)
extension_ids = self.env.cr.fetchall() extension_ids = self.env.cr.fetchall()
......
...@@ -21,7 +21,9 @@ class ShiftCounterEvent(models.Model): ...@@ -21,7 +21,9 @@ class ShiftCounterEvent(models.Model):
points_after_removal = points_before_removing_points + vals['point_qty'] points_after_removal = points_before_removing_points + vals['point_qty']
_logger.info("points_after_removal = %s", str(points_after_removal)) _logger.info("points_after_removal = %s", str(points_after_removal))
if points_after_removal <= suspension_limit or points_after_removal <= unsubscribe_limit: if points_after_removal <= suspension_limit or points_after_removal <= unsubscribe_limit:
if points_after_removal <= suspension_limit: if (points_after_removal <= suspension_limit
and
res_partner[0].cooperative_state != 'delay'):
target_status = 'suspended' target_status = 'suspended'
if points_after_removal <= unsubscribe_limit: if points_after_removal <= unsubscribe_limit:
target_status = 'unsubscribed' target_status = 'unsubscribed'
......
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