Commit 27ac19fc by François C.

Correctifs suite remontées Antonin

parent df15e861
......@@ -58,7 +58,6 @@ class ResPartner(models.Model):
compute='_compute_lacagette_cooperative_state'
)
working_state = fields.Selection(
selection=WORKING_STATE_SELECTION, string='Working State', store=True,
compute='_compute_lacagette_working_state', help="This state depends on the"
......@@ -71,9 +70,12 @@ class ResPartner(models.Model):
default= 0)
@api.multi
def _compute_lacagette_working_state(self):
_logger.debug("Dans _compute_lacagette_working_state")
conf = self.env['ir.config_parameter']
unsubscribe_limit = int(conf.get_param("lacagette_membership.points_limit_to_get_unsubscribed"))
current_datetime = fields.Datetime.now()
for partner in self:
_logger.debug("partner_id = %s, cooperative_state = %s", str(partner.id), str(partner.cooperative_state))
......@@ -82,16 +84,10 @@ class ResPartner(models.Model):
is_exempted = partner.leave_ids.filtered(
lambda l: l.state == 'done' and l.start_date <= current_datetime and l.stop_date >=
current_datetime and l.partner_state == 'exempted')
_logger.debug("is_exempted = %s", str(is_exempted))
# _logger.debug("is_exempted = %s", str(is_exempted))
if is_exempted:
_logger.debug("On met le statut exempté")
state = 'exempted'
#for l in list(partner.leave_ids):
# if l.stop_date > current_datetime and l.partner_state == 'exempted':
# state = 'exempted'
# fulldata = l.read()
# _logger.debug("for l in partner.leave_ids")
# _logger.debug(str(fulldata))
if state != 'exempted':
if partner.is_associated_people is True:
state = partner.parent_id.cooperative_state
......@@ -110,13 +106,17 @@ class ResPartner(models.Model):
else:
points = partner.final_ftop_point
if points < 0:
if partner.date_alert_stop:
if partner.date_delay_stop > current_datetime:
state = 'delay'
else:
state = 'suspended'
if points <= unsubscribe_limit:
state = 'unsubscribed'
self.env['shift.counter.event'].unsubscribe_partner(partner, unsubscribe_limit, points)
else:
state = 'suspended'
if partner.date_alert_stop:
if partner.date_delay_stop > current_datetime:
state = 'delay'
else:
state = 'suspended'
else:
state = 'suspended'
else:
state = 'unsubscribed'
partner.working_state = state
......@@ -134,7 +134,7 @@ class ResPartner(models.Model):
# _logger.debug("Partner = %s", str(partner.read()))
_logger.debug("partner_id = %s, working_state = %s", str(partner.id), str(partner.working_state))
state = 'up_to_date'
if partner.is_member is False and partner.is_associated_people is False and partner.is_worker_member is False:
if partner.is_member is False and partner.is_associated_people is False:
state= 'not_concerned'
else:
if partner.is_associated_people:
......@@ -327,6 +327,9 @@ class ResPartner(models.Model):
_logger.info("valeurs recues pour write partner = %s", str(vals))
if 'cooperative_state' in vals:
self._write_state_change(vals['cooperative_state'])
if 'barcode_base' in vals:
vals['cooperative_state'] = 'unsubscribed'
vals['working_state'] = 'unsubscribed'
return super(ResPartner, self).write(vals)
......
......@@ -9,6 +9,8 @@ _logger = logging.getLogger(__name__)
class ShiftCounterEvent(models.Model):
_inherit = 'shift.counter.event'
technical_note = fields.Char(string="Technical note such as 'no trigger'", required=True)
def _alter_point_event_depending_on_makeups_total_count(self, res_partner, vals, suspension_limit):
"""
This code helps keeping the consistency between std_counter and makeup total count.
......@@ -88,7 +90,7 @@ class ShiftCounterEvent(models.Model):
'type': partner.shift_type,
'partner_id': partner.id,
'point_qty': points_update,
'note': 'no trigger'
'technical_note': 'no trigger'
}
self.env['shift.counter.event'].create(data)
......@@ -112,12 +114,14 @@ class ShiftCounterEvent(models.Model):
('date_stop', '>=', now)]):
ext.update({'date_stop': now})
try:
mail_template = self.env.ref('coop_membership.unsubscribe_email')
if mail_template:
mail_template.send_mail(partner.id)
except Exception as e:
_logger.error("run_unsubscribe_process - send mail : %s - Process not interrupted", str(e))
try:
mail_template = self.env.ref('coop_membership.unsubscribe_email')
if mail_template:
mail_template.send_mail(partner.id)
else:
_logger.error("run_unsubscribe_process - mail_template not found")
except Exception as e:
_logger.error("run_unsubscribe_process - send mail : %s - Process interrupted", str(e))
partner.update(new_values)
except Exception as e:
_logger.error("run_unsubscribe_process : %s", str(e))
......@@ -143,7 +147,7 @@ class ShiftCounterEvent(models.Model):
_logger.error("Counter shift type is not corresponding to partner shift_type : %s", str(to_consider_vals))
return None
# Do not continue if method has been triggered by a 'no trigger' created shift_counter_event (while executing unsubscribe_partner)
if 'note' in to_consider_vals and to_consider_vals == 'no trigger':
if 'technical_note' in to_consider_vals and to_consider_vals['technical_note'] == 'no trigger':
return None
points_after_computation = partner.final_ftop_point if partner.shift_type == "ftop" else partner.final_standard_point
target_status = None
......@@ -176,12 +180,19 @@ class ShiftCounterEvent(models.Model):
# don't block process if an error occurs here
_logger.error("Error during _update_partner_target_status : %s", str(e))
@api.model
def affect_associated_people(self, parent_id):
associated = self.env['res.partner'].search([('parent_id', '=', parent_id)])
if associated:
for a in associated:
a.recompute_member_states()
@api.model
def write(self, vals):
res = super(ShiftCounterEvent, self).write(vals)
_logger.info("Vals recues = %s", str(vals))
self._update_partner_target_status(vals)
self.affect_associated_people(vals['partner_id'])
return res
@api.model
......@@ -189,5 +200,6 @@ class ShiftCounterEvent(models.Model):
_logger.info("Vals recues creation = %s", str(vals))
res = super(ShiftCounterEvent, self).create(vals)
self._update_partner_target_status(vals)
self.affect_associated_people(vals['partner_id'])
return res
......@@ -33,4 +33,6 @@ class ShiftTemplateRegistrationLine(models.Model):
coop_state = 'unsubscribed'
member.update({'cooperative_state': coop_state})
_logger.info("new cooperative_state = %s for %s", coop_state, str(member.id))
_logger.info("On va recalculer le statut du membre = %s", str(member.id))
member.recompute_member_states()
return super_res
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