Commit f2d6ab89 by François C.

Correctif traitement des rattrapages à faire (suivant que ça vienne du compteur…

Correctif traitement des rattrapages à faire (suivant que ça vienne du compteur de points seul ou de l'absence à un service)
parent 1bc14e83
......@@ -46,9 +46,14 @@ class ResPartner(models.Model):
# Columns Section
makeups_to_do = fields.Integer(
"Number of make-ups to done",
"Number of make-ups to do",
default= 0)
makeups_to_add = fields.Integer(
"Number of make-ups to add (set by shift_registration)",
default= 0)
# To be removed
target_status = fields.Selection(
selection=TARGET_STATUS_SELECTION, default='')
......
......@@ -134,7 +134,10 @@ class ShiftCounterEvent(models.Model):
try:
if 'point_qty' in vals and vals['point_qty'] < 0:
res_partner = self.env['res.partner'].search([('id', '=', vals['partner_id'])])
res_partner[0].update({'makeups_to_do': res_partner[0].makeups_to_do + 1})
to_add = abs(vals['point_qty'])
if res_partner[0].makeups_to_add != 0:
to_add = res_partner[0].makeups_to_add
res_partner[0].update({'makeups_to_do': res_partner[0].makeups_to_do + to_add, 'makeups_to_add': 0})
return 0
except Exception as e:
_logger.error("_update_partner_makeups_to_do : %s", str(e))
......@@ -199,7 +202,7 @@ class ShiftCounterEvent(models.Model):
@api.model
def write(self, vals):
_logger.info("Vals recues = %s", str(vals))
_logger.debug("Vals recues = %s", str(vals))
self._update_partner_makeups_to_do(vals)
res = super(ShiftCounterEvent, self).write(vals)
self._update_partner_target_status(vals)
......@@ -208,7 +211,7 @@ class ShiftCounterEvent(models.Model):
@api.model
def create(self, vals):
_logger.info("Vals recues creation = %s", str(vals))
_logger.debug("Vals recues creation = %s", str(vals))
self._update_partner_makeups_to_do(vals)
res = super(ShiftCounterEvent, self).create(vals)
self._update_partner_target_status(vals)
......
......@@ -41,6 +41,5 @@ class ShiftRegistration(models.Model):
# Missing a makeup leads to have an additional makeup (the shift you initialy missed + the makeup you missed)
if s.is_makeup is True:
to_add += 1
new_makeups_to_do = s.partner_id.makeups_to_do + to_add
s.partner_id.update({'makeups_to_do': new_makeups_to_do})
return super(ShiftRegistration, self).write(vals)
\ No newline at end of file
s.partner_id.update({'makeups_to_add': to_add})
return super(ShiftRegistration, self).write(vals)
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