Commit 5d5cd2a4 by François C.

Fix exempted status case when computing working_state

parent 200bd451
...@@ -78,16 +78,31 @@ class ResPartner(models.Model): ...@@ -78,16 +78,31 @@ class ResPartner(models.Model):
for partner in self: for partner in self:
_logger.debug("partner_id = %s, cooperative_state = %s", str(partner.id), str(partner.cooperative_state)) _logger.debug("partner_id = %s, cooperative_state = %s", str(partner.id), str(partner.cooperative_state))
state = 'up_to_date' state = 'up_to_date'
if partner.is_associated_people is True: if partner.leave_ids:
state = partner.parent_id.cooperative_state is_exempted = partner.leave_ids.filtered(
else: lambda l: l.state == 'done' and l.start_date <= current_datetime and l.stop_date >=
if partner.cooperative_state in ['gone', 'associated']: current_datetime and l.partner_state == 'exempted')
state = partner.cooperative_state _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
else: else:
potential_associated_record = self.env['res.partner'].search([('email','=',self.email), ('is_associated_people', '=', True)]) if partner.cooperative_state in ['gone', 'associated']:
if potential_associated_record: state = partner.cooperative_state
else:
potential_associated_record = self.env['res.partner'].search([('email','=',self.email), ('is_associated_people', '=', True)])
if potential_associated_record:
state = 'associated' state = 'associated'
else: else:
if partner.is_unsubscribed is False: if partner.is_unsubscribed is False:
points = 0 points = 0
if partner.shift_type == 'standard': if partner.shift_type == 'standard':
...@@ -277,9 +292,15 @@ class ResPartner(models.Model): ...@@ -277,9 +292,15 @@ class ResPartner(models.Model):
def set_special_state(self, cr, uid, partner, context=None): def set_special_state(self, cr, uid, partner, context=None):
new_state = partner['state']
if partner['state'] == 'cancel_special': if partner['state'] == 'cancel_special':
partner['state'] = 'unsubscribed' new_state = 'unsubscribed'
return self.write(cr, uid, [partner['id']], {'cooperative_state': partner['state'], 'working_state': partner['state']} , context=context) write_result = self.write(cr, uid, [partner['id']], {'cooperative_state': new_state, 'working_state': new_state} , context=context)
if new_state == 'unsubscribed':
member = self.pool.get('res.partner').browse(cr, uid, partner['id'], context)
return member.recompute_member_states()
else:
return write_result
def _write_state_change(self, state): def _write_state_change(self, state):
data = {'member_id': self.id, 'state': state} data = {'member_id': self.id, 'state': state}
......
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