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 <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-31 11:23:27 -04:00
parent 3f78f652e7
commit 1a1ab2da4f
3 changed files with 20 additions and 6 deletions

View File

@@ -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': """

View File

@@ -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:

View File

@@ -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),