From 1a1ab2da4fb47c05630883d0b7e288b564ac7e52 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Sun, 31 May 2026 11:23:27 -0400 Subject: [PATCH] fix(fusion_clock): tz resolver uses company.partner_id.tz (res.company has no tz in Odoo 19) _resolve_tz fell back to env.company.tz, which raises AttributeError for any user without a personal tz (surfaced by the new list-wide pay-period filters, which resolve a company-level tz). Use env.company.partner_id.tz. Regression test added. Bump 3.15.0 -> 3.15.1. Co-Authored-By: Claude Opus 4.8 --- fusion_clock/__manifest__.py | 2 +- fusion_clock/models/tz_utils.py | 12 +++++++----- fusion_clock/tests/test_pay_period.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/fusion_clock/__manifest__.py b/fusion_clock/__manifest__.py index a0a816e3..87ce4175 100644 --- a/fusion_clock/__manifest__.py +++ b/fusion_clock/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Fusion Clock', - 'version': '19.0.3.15.0', + 'version': '19.0.3.15.1', 'category': 'Human Resources/Attendances', 'summary': 'Complete Employee T&A with Geofencing, Shifts, Penalties, Overtime, Kiosk, Dashboard & Payroll Export', 'description': """ diff --git a/fusion_clock/models/tz_utils.py b/fusion_clock/models/tz_utils.py index 0a2676f1..c7ca0811 100644 --- a/fusion_clock/models/tz_utils.py +++ b/fusion_clock/models/tz_utils.py @@ -10,10 +10,12 @@ date boundaries, and display strings in the **user's local timezone** so that queries, penalties, and UI all reflect the real calendar day. Timezone resolution order: - 1. Explicit employee.tz (if an employee record is available) - 2. env.user.tz (logged-in portal / backend user) - 3. env.company.tz (company-level default) - 4. 'UTC' (last resort — should rarely happen) + 1. Explicit employee.tz (if an employee record is available) + 2. env.user.tz (logged-in portal / backend user) + 3. env.company.partner_id.tz (company-level default; res.company has + no tz field in Odoo 19 — it lives on the + company's partner) + 4. 'UTC' (last resort — should rarely happen) """ import pytz @@ -25,7 +27,7 @@ def _resolve_tz(env, employee=None): tz_name = ( (employee.tz if employee else None) or env.user.tz - or env.company.tz + or (env.company.partner_id.tz if env.company.partner_id else None) or 'UTC' ) try: diff --git a/fusion_clock/tests/test_pay_period.py b/fusion_clock/tests/test_pay_period.py index d3bf14bc..4a794ec6 100644 --- a/fusion_clock/tests/test_pay_period.py +++ b/fusion_clock/tests/test_pay_period.py @@ -84,6 +84,18 @@ class TestPayPeriodFilters(TransactionCase): 'check_out': eight_ago, }) + def test_resolve_tz_company_fallback_when_user_has_no_tz(self): + # Regression: res.company has no `tz` field in Odoo 19; the resolver must + # fall back to env.company.partner_id.tz, not env.company.tz, or a + # tz-less user crashes the period filters with AttributeError. + self.env.user.tz = False + self.env.company.partner_id.tz = 'America/Toronto' + res = self.env['hr.attendance'].search([ + ('employee_id', '=', self.emp.id), + ('x_fclk_in_current_period', '=', True), + ]) + self.assertIn(self.att_current, res) + def test_current_filter_returns_only_current(self): res = self.env['hr.attendance'].search([ ('employee_id', '=', self.emp.id),