Skip to content

Conversation

@kanda999
Copy link
Contributor

@kanda999 kanda999 commented Jan 7, 2026

Non-admin users could get an AccessError when creating a timesheet sheet because it triggers a write on hr.attendance.

@qrtl QT6155

…n-admin users

Non-admin users could get an AccessError when creating a timesheet sheet because it triggers a write on hr.attendance.
]
)
attendances._compute_sheet_id()
attendances.sudo()._compute_sheet_id()
Copy link
Member

Choose a reason for hiding this comment

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

Add compute_sudo=True to the field instead?

Copy link
Contributor Author

@kanda999 kanda999 Jan 8, 2026

Choose a reason for hiding this comment

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

I tried adding compute_sudo=True to sheet_id = fields.Many2one(...), but it didn’t work.
Since _compute_sheet_id is called from create, it seems that create needs to be executed with sudo().

Returns last attendance record"""

return self.employee_id._attendance_action_change()
return self.employee_id.sudo()._attendance_action_change()
Copy link
Member

Choose a reason for hiding this comment

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

Can you double-check if this is a valid fix. Wouldn't this allow updating attendance records of other employees?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part seems to require sudo() to write to hr.attendance.
The write access to hr.attendance is handled the same way in Odoo’s standard code as well.
https://github.com/odoo/odoo/blob/ad1c367d9d3e14cb7196416e117a13b8a11e9d12/addons/hr_attendance/controllers/main.py#L135-L139

Copy link
Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

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

Code review. LGTM.

Copy link

@AungKoKoLin1997 AungKoKoLin1997 left a comment

Choose a reason for hiding this comment

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

LGTM

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@ivs-cetmix
Copy link
Member

Hey @kanda999 thank you for your contribution!
/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 18.0-ocabot-merge-pr-858-by-ivs-cetmix-bump-patch, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Jan 26, 2026
Signed-off-by ivs-cetmix
@OCA-git-bot
Copy link
Contributor

It looks like something changed on 18.0 in the meantime.
Let me try again (no action is required from you).
Prepared branch 18.0-ocabot-merge-pr-858-by-ivs-cetmix-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit f30c907 into OCA:18.0 Jan 26, 2026
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at a3618e9. Thanks a lot for contributing to OCA. ❤️

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