|
|
@@ -631,6 +631,31 @@ class HrEfficiency(models.Model):
|
|
|
_logger.error(f"Error during dynamic system initialization: {str(e)}")
|
|
|
raise
|
|
|
|
|
|
+ @api.model
|
|
|
+ def _post_init_hook(self):
|
|
|
+ """
|
|
|
+ Post-install hook to ensure dynamic fields are created for existing indicators
|
|
|
+ """
|
|
|
+ import logging
|
|
|
+ _logger = logging.getLogger(__name__)
|
|
|
+
|
|
|
+ try:
|
|
|
+ _logger.info("Running post-install hook for hr_efficiency module")
|
|
|
+
|
|
|
+ # Ensure all active indicators have manual fields
|
|
|
+ active_indicators = self.env['hr.efficiency.indicator'].search([('active', '=', True)])
|
|
|
+ for indicator in active_indicators:
|
|
|
+ self.env['hr.efficiency.indicator']._create_dynamic_field(indicator)
|
|
|
+
|
|
|
+ # Update views with dynamic fields
|
|
|
+ self._update_views_with_dynamic_fields()
|
|
|
+
|
|
|
+ _logger.info(f"Post-install hook completed. Processed {len(active_indicators)} indicators")
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ _logger.error(f"Error in post-install hook: {str(e)}")
|
|
|
+ raise
|
|
|
+
|
|
|
@api.model
|
|
|
def _update_views_with_dynamic_fields(self):
|
|
|
"""
|