|
@@ -502,10 +502,34 @@ class HrEfficiency(models.Model):
|
|
|
'actual_non_billable_hours'
|
|
'actual_non_billable_hours'
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
+ # Check basic fields
|
|
|
for field in fields_to_compare:
|
|
for field in fields_to_compare:
|
|
|
if abs(efficiency_data[field] - latest_record[field]) > 0.01: # Tolerance for floating point
|
|
if abs(efficiency_data[field] - latest_record[field]) > 0.01: # Tolerance for floating point
|
|
|
has_changes = True
|
|
has_changes = True
|
|
|
break
|
|
break
|
|
|
|
|
+
|
|
|
|
|
+ # If no changes in basic fields, check dynamic indicators
|
|
|
|
|
+ if not has_changes:
|
|
|
|
|
+ # Get all active indicators
|
|
|
|
|
+ active_indicators = self.env['hr.efficiency.indicator'].search([('active', '=', True)])
|
|
|
|
|
+
|
|
|
|
|
+ for indicator in active_indicators:
|
|
|
|
|
+ field_name = self._get_indicator_field_name(indicator.name)
|
|
|
|
|
+
|
|
|
|
|
+ # Calculate current indicator value
|
|
|
|
|
+ current_value = indicator.evaluate_formula(efficiency_data)
|
|
|
|
|
+
|
|
|
|
|
+ # Get previous indicator value from record
|
|
|
|
|
+ previous_value = getattr(latest_record, field_name, None)
|
|
|
|
|
+
|
|
|
|
|
+ # Compare values with tolerance
|
|
|
|
|
+ if (current_value is not None and previous_value is not None and
|
|
|
|
|
+ abs(current_value - previous_value) > 0.01):
|
|
|
|
|
+ has_changes = True
|
|
|
|
|
+ break
|
|
|
|
|
+ elif current_value != previous_value: # Handle None vs value cases
|
|
|
|
|
+ has_changes = True
|
|
|
|
|
+ break
|
|
|
else:
|
|
else:
|
|
|
# No previous record exists, so this is a change
|
|
# No previous record exists, so this is a change
|
|
|
has_changes = True
|
|
has_changes = True
|