Commit d5d72a5a by François C.

Change to consider shift_type in LaCagette Membership, instead of admitting…

Change to consider shift_type in LaCagette Membership, instead of admitting everybody has subscribed ftop type shift templates
parent 7e9aa8a0
<?xml version="1.0"?>
<odoo noupdate="1">
<record id="points_limit_to_get_suspended" model="ir.config_parameter">
<field name="key">lacagette_membership.points_limit_to_get_suspended</field>
<field name="value">-2</field>
......
......@@ -31,13 +31,15 @@ class ResPartner(models.Model):
for p in self.env['res.partner']\
.search([('target_status', '!=', "")]):
try:
new_values = {'target_status': "", "date_alert_stop": False}
if p.final_ftop_point < 0:
final_points = p.final_ftop_point if p.shift_type == "ftop" else p.final_standard_point
if final_points < 0:
new_values['cooperative_state'] = p.target_status
if new_values['cooperative_state'] == "unsubscribed":
new_values['makeups_to_do'] = 2 if absence_status == 'absent' else 1
new_values['final_ftop_point'] = -2
new_values['display_ftop_points'] = -2
new_values['final_' + p.shift_type + '_point'] = -2
new_values['display_' + p.shift_type + '_points'] = -2
"""
unlink model: "shift.template.registration"
to delete all future shifts linked to this coop.
......@@ -49,6 +51,8 @@ class ResPartner(models.Model):
if mail_template:
mail_template.send_mail(p.id)
p.update(new_values)
except Exception as e:
_logger.error("run_process_target_status : %s", str(e))
#@api.onchange('cooperativestate') : could be used only if it is called from client
@api.model
......@@ -103,7 +107,7 @@ class ResPartner(models.Model):
@api.model
def update(self, vals):
#_logger.info("valeurs reçues pour update partner = %s", str(vals))
_logger.info("valeurs reçues pour update partner = %s", str(vals))
state_to_record = ""
if 'cooperative_state' in vals:
state_to_record = vals['cooperative_state']
......@@ -116,11 +120,11 @@ class ResPartner(models.Model):
return super(ResPartner, self).update(vals)
@api.model
def write(self, vals):
# _logger.info("valeurs reçues pour write partner = %s", str(vals))
_logger.info("valeurs reçues pour write partner = %s", str(vals))
if 'cooperative_state' in vals:
self._write_state_change(vals['cooperative_state'])
return super(ResPartner, self).write(vals)
\ No newline at end of file
......@@ -17,18 +17,19 @@ class ShiftCounterEvent(models.Model):
if vals['point_qty'] < 0:
res_partner = self.env['res.partner'].search([('id', '=', vals['partner_id'])])
if res_partner:
points_before_removing_points = res_partner[0].final_ftop_point
p = res_partner[0]
points_before_removing_points = p.final_ftop_point if p.shift_type == "ftop" else p.final_standard_point
points_after_removal = points_before_removing_points + vals['point_qty']
_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
and
res_partner[0].cooperative_state != 'delay'):
p.cooperative_state != 'delay'):
target_status = 'suspended'
if points_after_removal <= unsubscribe_limit:
target_status = 'unsubscribed'
res_partner[0].update({'target_status': target_status,
'current_cooperative_state': res_partner[0].cooperative_state})
p.update({'target_status': target_status,
'current_cooperative_state': p.cooperative_state})
@api.model
def write(self, vals):
......@@ -43,4 +44,3 @@ class ShiftCounterEvent(models.Model):
_logger.info("Vals reçues creation = %s", str(vals))
return super(ShiftCounterEvent, self).create(vals)
\ 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