This commit avoids a traceback when trying to install hr_timesheet post
to "hours" uom deletion.
Steps
=====
- Install module sale_management
- In Settings > Sales > Product Catalog section, activate the option
Units of Measure
- Go to Units of Measure configuration menu
- Remove the unit of measure "Hours"
- Install hr_timesheet
Issue
=====
A traceback appears indicating: "Cannot update missing record
'uom.product_uom_hour'"
Cause
=====
Since
https://github.com/odoo/odoo/commit/ab76c421c279b26195396b61e66b3e8853785226,
deletion of system uom is prohibited. An exception exists for uom
"Hours" that can be deleted without warning. This exception is removed
inside hr_timesheet as this uom is needed in this module. However, it
can still be deleted prior to hr_timesheet installation.
When it is deleted, the installation of hr_timesheet raises a traceback
as the data file hr_timesheet_data tries to access and update this
record.
Fix
===
Before updating the record uom "hours" in the data file, a call to a
method ensure_iom_hours is made. This method recreate this uom if it
does not exist in the database anymore.
task-3551315
closesodoo/odoo#141572
X-original-commit: 0d520e5e7c4b8b17ab1865a3010bbce87a71ec62
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>