| 1234567891011121314151617181920212223242526272829303132 |
- #!/usr/bin/env python3
- """
- Script to force recompute expected_hours_to_date field for existing records
- """
- import odoo
- from odoo import api, fields, models
- from odoo.tools import config
- def main():
- # Initialize Odoo
- odoo.cli.server.main()
-
- # Get environment
- env = api.Environment(cr, uid, {})
-
- # Get all hr.efficiency records
- efficiency_records = env['hr.efficiency'].search([('active', '=', True)])
-
- print(f"Found {len(efficiency_records)} efficiency records to update")
-
- # Force recompute of expected_hours_to_date field
- for record in efficiency_records:
- record._compute_expected_hours_to_date()
- print(f"Updated record {record.id}: {record.employee_id.name} - {record.month_year} - Expected: {record.expected_hours_to_date}")
-
- # Commit changes
- env.cr.commit()
- print("All records updated successfully!")
- if __name__ == "__main__":
- main()
|