Skip to content

[19.0][MIG] hr_attendance#5705

Open
hbrunn wants to merge 2 commits into
OCA:19.0from
hbrunn:19.0-hr_attendance
Open

[19.0][MIG] hr_attendance#5705
hbrunn wants to merge 2 commits into
OCA:19.0from
hbrunn:19.0-hr_attendance

Conversation

@hbrunn

@hbrunn hbrunn commented Jun 9, 2026

Copy link
Copy Markdown
Member

No description provided.

@hbrunn hbrunn added this to the 19.0 milestone Jun 9, 2026
@hbrunn

hbrunn commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

/ocabot migration hr_attendance

Depends on :

@legalsylvain

This comment was marked as duplicate.

@hbrunn

This comment was marked as off-topic.

@legalsylvain

This comment was marked as off-topic.

@hbrunn

This comment was marked as off-topic.

@legalsylvain

This comment was marked as off-topic.

@hbrunn

This comment was marked as off-topic.

@legalsylvain

This comment was marked as off-topic.

@hbrunn

hbrunn commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

@legalsylvain done in #5745, now setting our whole discussion as off-topic

@legalsylvain

Copy link
Copy Markdown
Contributor

@legalsylvain done in #5745, now setting our whole discussion as off-topic

thanks a lot for this Job. I manually run the script a last time for the V19. new 19 PR should be handled by your script.

---Models in module 'hr_attendance'---
obsolete model hr.attendance.overtime (renamed to hr.attendance.overtime.line)
new model hr.attendance.overtime.line (renamed from hr.attendance.overtime)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why adding these empty lines that makes the reading harder? I think the comment should be together with the analysis lines block.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I think the empty lines improve readability. If that's so important to you, add it to https://oca.github.io/OpenUpgrade/090_contribute.html#how-to-contribute-new-migration-scripts and I'll bulk update the whole branch, as I've been doing this for a long time


# NOTHING TO DO

hr_attendance / hr.attendance / in_location (char) : NEW

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reorganize this line into in_city DEL comment for seeing both together and to understand the change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard disagree about reordering lines in the work file. I want to be able to say diff upgrade_analysis* to easily verify all lines from the generated file are in the work file (=only whitespace or comments in the diff)

# date is required in v19, fill with create_date if empty, possibly wrong
env.cr.execute(
f"""
UPDATE hr_attendance_overtime_line SET date=(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not get it the same from the nearest attendance record?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you propose to find the nearest record? create_date? that's just as prone to filling in a wrong date here.

I consider overtime lines without date garbage data which people should clean up, and do the update only to satisfy the non-null constraint

SQL_EMPLOYEE2TZ = """
(
SELECT
hr_employee.id employee_id,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find you new SQL style a bit difficult to read, and very vertical scroll intensive. Either indent the lines after the command (SELECT, FROM, etc), or put them in the same line as always.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not so new, but indeed was lacking indentation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the link, this formatting does not follow the recommended style https://docs.telemetry.mozilla.org/concepts/sql_style.html#join-conditions
Image

Suggested change
hr_employee.id employee_id,
FROM
hr_employee
JOIN
resource_resource
ON hr_employee.resource_id=resource_resource.id
LEFT JOIN
resource_calendar
ON resource_resource.calendar_id=resource_calendar.id
JOIN
res_company
ON hr_employee.company_id=res_company.id
LEFT JOIN
resource_calendar company_resource_calendar
ON res_company.resource_calendar_id=company_resource_calendar.id

WHERE
hr_attendance.employee_id=hr_attendance_overtime_line.employee_id
AND
hr_attendance.date=hr_attendance_overtime_line.date

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part may not fit according current code, and even more, we may have more than one record for the same date.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which code do you mean? and indeed this can lead to updating the same record multiple times, but how does this matter?

"""
Pre-fill hr.attendance#date
"""
openupgrade.add_fields(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using add_fields instead of add_columns or a simply ALTER TABLE?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question, changed to add_columns

@OCA-git-bot OCA-git-bot added mod:openupgrade_scripts Module openupgrade_scripts series:19.0 labels Jun 30, 2026

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TT58628

SQL_EMPLOYEE2TZ = """
(
SELECT
hr_employee.id employee_id,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the link, this formatting does not follow the recommended style https://docs.telemetry.mozilla.org/concepts/sql_style.html#join-conditions
Image

Suggested change
hr_employee.id employee_id,
FROM
hr_employee
JOIN
resource_resource
ON hr_employee.resource_id=resource_resource.id
LEFT JOIN
resource_calendar
ON resource_resource.calendar_id=resource_calendar.id
JOIN
res_company
ON hr_employee.company_id=res_company.id
LEFT JOIN
resource_calendar company_resource_calendar
ON res_company.resource_calendar_id=company_resource_calendar.id

Comment on lines +170 to +181
openupgrade.add_columns(
env,
[
(
"hr.attendance",
"validated_overtime_hours",
"float",
None,
"hr_attendance",
)
],
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field already exists in v18 and is computed and stored, so why is it necessary to add the column?
The logic used to compute the field has changed slightly, but I understand that adding the column should not be necessary.

https://github.com/odoo/odoo/blob/e88fb3a5f5c2239f2a3f434a4ac3052e3e156ef1/addons/hr_attendance/models/hr_attendance.py#L49

Comment on lines +113 to +114
NEW hr.attendance.overtime.rule: hr_attendance.hr_attendance_overtime_employee_schedule_rule (noupdate)
NEW hr.attendance.overtime.rule: hr_attendance.hr_attendance_overtime_non_working_days_rule (noupdate)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should force the creation of these records to preserve the behavior from v18

In v18, there are two company-level fields used to configure tolerance for both the employee and the company. Odoo did not remove these fields(see), but the implementation is now handled by the new hr.attendance.overtime.ruleset model.

Image Image

If these fields are set in my database, attendance records are taken into account when computing extra hours. However, in v19, if the corresponding rules are missing and the ruleset_id field is not set on hr.version, extra hours are not computed correctly.

Image

These records are not created because they are inside a noupdate block with forcecreate="0" see this file. In addition, we need to transfer the values from the company fields to the corresponding rule.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants