Skip to content

[17.0][18.0][19.0] helpdesk_mgmt_timesheet: Undefined variable 'nbCols' in timesheet_table report template #1057

Description

@stephansainleger

Module

helpdesk_mgmt_timesheet

Describe the bug

The template helpdesk_mgmt_timesheet.timesheet_table references the undefined variable nbCols (t-value="nbCols + 1"), which was removed from the parent template hr_timesheet.timesheet_table in Odoo 17.0, causing a NameError when rendering the timesheet report with tickets.

To Reproduce

Affected versions: 17.0, 18.0, 19.0 (migration PR #999)

Steps to reproduce the behavior:

  1. Install helpdesk_mgmt_timesheet on Odoo 17.0+ (or 18.0, or the 19.0 migration PR)
  2. Create a ticket linked to a project/task with timesheets
  3. As a user with helpdesk_mgmt.group_helpdesk_user, view a timesheet line that has a ticket_id
  4. Try to print the timesheet report (e.g. from the ticket or project)
  5. The report fails to render with a NameError on nbCols

Current behavior

The inheritance template at report/report_timesheet_templates.xml tries to increment a variable nbCols that no longer exists in the parent template:

<xpath expr="//table[hasclass('table-sm')]/tbody/tr[2]/td" position="before">
    <t t-if="show_ticket"
        t-set="nbCols"
        t-value="nbCols + 1"
        groups="helpdesk_mgmt.group_helpdesk_user"/>
</xpath>

In Odoo 17.0+, the parent template hr_timesheet.timesheet_table replaced the dynamic colspan logic (t-attf-colspan="{{nbCols}}") with a static colspan="100". Since nbCols is never defined in the parent scope, evaluating nbCols + 1 raises a NameError when show_ticket is True and the user has the helpdesk group.

This bug was introduced during the 16.0→17.0 migration, carried over to 18.0 without detection, and the current 19.0 migration PR (#999) also copies the same broken code.

Expected behavior
The 3rd xpath block (setting nbCols) should be removed, as the parent template now uses colspan="100" which spans all columns automatically. The two other xpaths (adding the Ticket column header and data cell) are sufficient and work correctly.

Additional context
Fix proposed tested successfully.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions