Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Discuss

Entity: mail.tracking.duration.mixin

Compute Method: _compute_rotting

Inputs Method Outputs
  • rotting_threshold_days
  • date_last_stage_update
  • create_date
"""
        A resource is rotting if its stage has not been updated in a number of days depending on its
        stage's rotting_threshold_days value, assuming it matches _get_rotting_domain() conditions.

        If the rotting_threshold_days field is not defined on the tracked module,
        or if the value of rotting_threshold_days is 0,
        then the resource will never rot.
        """
if not self._is_rotting_feature_enabled():
            self.is_rotting = False
            self.rotting_days = 0
            return
now = self.env.cr.now()
rot_enabled = self.filtered_domain(self._get_rotting_domain())
others = self - rot_enabled
for stage, records in rot_enabled.grouped(self._track_duration_field).items():
            rotting = records.filtered(lambda record:
                (record.date_last_stage_update or record.create_date or fields.Datetime.now())
                + timedelta(days=stage.rotting_threshold_days) < now
            )
            for record in rotting:
                record.is_rotting = True
                record.rotting_days = (now - (record.date_last_stage_update or record.create_date)).days
            others += records - rotting
others.is_rotting = False
others.rotting_days = 0

Back to entity