1) forbid deletion of main uoms & categories 2) warn modifications of main uoms data. Except for the working Hours uom, which isn't a strict UoM representation and could change between countries (and/or be deleted). 3) Also move the Dozen UoM to demo datas, it's a confusing UoM and isn't used by the majority of databases. 4) Restrict deletion of used uoms on main models. On sale orders and account moves the uoms couldn't be deleted thanks to the SQL constraint covering the display_type logic, but the generic error message is more clear for a user when deleting an uom.
19 lines
579 B
Python
19 lines
579 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class Uom(models.Model):
|
|
_inherit = 'uom.uom'
|
|
|
|
def _unprotected_uom_xml_ids(self):
|
|
# Override
|
|
# When timesheet App is installed, we also need to protect the hour UoM
|
|
# from deletion (and warn in case of modification)
|
|
return [
|
|
"product_uom_dozen",
|
|
]
|
|
|
|
timesheet_widget = fields.Char("Widget", help="Widget used in the webclient when this unit is the one used to encode timesheets.")
|