odoo/odoo#204316

Created by Aditi Patel (adip)
Closed
label
odoo-dev:17.0-sentry-6489805050-sale_timesheet-parse-error-adip
head
eb53a6a0699fac6e125ef62ed1240a28a0ca65a2
odoo/odoo
17.0 #204316

[FIX] sale_timesheet: prevent installation error if record rule is missing

Currently, an error occurs when installing or upgrading the sale_timesheet module if the user has manually deleted the referenced record rule.

Steps to reproduce:
- Install the account module.
- Delete the account.analytic.line.readonly.user record rule.
- Install the sale_timesheet module.
- Observe the error.

Error:
ParseError: while parsing /home/odoo/src/odoo/saas-18.2/addons/sale_timesheet/security/sale_timesheet_security.xml ...

The issue occurs because the sale_timesheet module overrides the account.account_analytic_line_rule_readonly_user record rule in its security XML file - [1]. However, if the parent rule is missing, the system fails to apply the override, resulting in a ParseError.

[1] - https://github.com/odoo/odoo/blob/9c864204e84b2d769eeedffe6aa2b2263cf3889f/addons/sale_timesheet/security/sale_timesheet_security.xml#L11

This commit ensures that the rules are only updated if they already exist, avoiding an error if the referenced rule has been deleted.

Sentry - 6489805050