Commit 200bd451 by François C.

6833--Rectificatifs pour gestion des changements de statuts (surcharge modules awesomefoodcoops)

parent 13c541f0
......@@ -16,7 +16,7 @@
#
'category': 'Uncategorized',
'version': '0.0.7.4',
'version': '0.0.7.5',
# any module necessary for this one to work correctly
'depends': ['base', 'coop_membership', 'coop_shift'],
......
......@@ -37,7 +37,8 @@ WORKING_STATE_SELECTION = [
('delay', 'Delay'),
('blocked', 'Blocked'),
('gone', 'Gone'),
('associated', 'Associated')
('associated', 'Associated'),
('unsubscribed', 'Unsubscribed')
]
class ResPartner(models.Model):
......@@ -68,55 +69,79 @@ class ResPartner(models.Model):
extra_shift_done = fields.Integer(
"Number of shift done with both of the associate",
default= 0)
@api.multi
def _compute_lacagette_working_state(self):
_logger.debug("Dans _compute_lacagette_working_state")
current_datetime = fields.Datetime.now()
for partner in self:
_logger.debug("partner_id = %s, cooperative_state = %s", str(partner.id), str(partner.cooperative_state))
state = 'up_to_date'
if partner.is_associated_people is True:
partner.working_state = partner.parent_id.cooperative_state
state = partner.parent_id.cooperative_state
else:
if partner.cooperative_state in ['gone', 'associated']:
partner.working_state = partner.cooperative_state
state = partner.cooperative_state
else:
potential_associated_record = self.env['res.partner'].search([('email','=',self.email), ('is_associated_people', '=', True)])
if potential_associated_record:
partner.working_state = 'associated'
# Not sure, it is useful, but _compute_working_state is overriden, calling our own method
state = 'associated'
else:
if partner.is_unsubscribed is False:
points = 0
if partner.shift_type == 'standard':
points = partner.final_standard_point
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'
else:
state = 'suspended'
else:
state = 'unsubscribed'
partner.working_state = state
# Overriding by calling our own method (which is mentionned in field declaration)
@api.depends('is_blocked', 'final_standard_point', 'final_ftop_point', 'shift_type', 'date_alert_stop', 'date_delay_stop', 'leave_ids.state')
@api.multi
def _compute_working_state(self):
self._compute_lacagette_working_state()
@api.depends(
'working_state', 'is_unpayed', 'is_unsubscribed',
'is_worker_member', 'is_associated_people',
'parent_id.cooperative_state')
@api.multi
def _compute_lacagette_cooperative_state(self):
_logger.debug("Dans _compute_lacagette_cooperative_state")
for partner in self:
# _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:
partner.cooperative_state = 'not_concerned'
state= 'not_concerned'
else:
if partner.is_associated_people:
# Associated People
partner.cooperative_state = partner.parent_id.cooperative_state
elif partner.is_worker_member:
state = partner.parent_id.cooperative_state
elif partner.is_member:
# Type A Subscriptor
if partner.is_unsubscribed and partner.working_state not in ['gone', 'associated']:
partner.cooperative_state = 'unsubscribed'
state = 'unsubscribed'
elif partner.is_unpayed:
partner.cooperative_state = 'unpayed'
state = 'unpayed'
elif partner.working_state:
state = partner.working_state
else:
partner.cooperative_state = partner.working_state
partner.working_state = state
partner.cooperative_state = state
_logger.debug("A l'issue du traitement partner_id = %s, working_state = %s, cooperative_state = %s", str(partner.id), str(partner.working_state), str(partner.cooperative_state))
# Not sure, it is useful, but _compute_cooperative_state is overriden, calling our own method
# Overriding by calling our own method (which is mentionned in field declaration)
@api.depends(
'working_state', 'is_unpayed', 'is_unsubscribed',
'is_worker_member', 'is_associated_people',
......
......@@ -84,8 +84,12 @@ class ShiftCounterEvent(models.Model):
if points_after_removal <= unsubscribe_limit:
target_status = 'unsubscribed'
if target_status is not None:
p.update({'target_status': target_status,
'current_cooperative_state': p.cooperative_state})
p.update({'working_state': target_status, 'cooperative_state': target_status})
# p.update({'target_status': target_status,
# 'current_cooperative_state': p.cooperative_state})
elif points_after_removal >= 0:
p.update({'working_state': 'up_to_date', 'cooperative_state': 'up_to_date'})
except Exception as e:
# don't block process if an error occurs here
_logger.error("Error during _update_partner_target_status : %s", str(e))
......
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