diff --git a/addons/project/data/project_data.xml b/addons/project/data/project_data.xml index 127b5b1366b..3103992a4e6 100644 --- a/addons/project/data/project_data.xml +++ b/addons/project/data/project_data.xml @@ -2,11 +2,6 @@ - - - - - diff --git a/addons/project/models/res_company.py b/addons/project/models/res_company.py index 550bff5ad53..afad6d1b54e 100644 --- a/addons/project/models/res_company.py +++ b/addons/project/models/res_company.py @@ -1,14 +1,23 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import api, fields, models class ResCompany(models.Model): _inherit = 'res.company' + @api.model + def _default_project_time_mode_id(self): + uom = self.env.ref('uom.product_uom_hour', raise_if_not_found=False) + if not uom: + uom = self.env['uom.uom'].search([('measure_type', '=', 'time'), ('uom_type', '=', 'reference')], limit=1) + if not uom: + uom = self.env['uom.uom'].search([('measure_type', '=', 'time')], limit=1) + return uom + project_time_mode_id = fields.Many2one('uom.uom', string='Project Time Unit', - default=lambda s: s.env.ref('uom.product_uom_hour', raise_if_not_found=False), + default=_default_project_time_mode_id, domain=[('measure_type', '=', 'time')], help="This will set the unit of measure used in projects and tasks.\n" "If you use the timesheet linked to projects, don't " "forget to setup the right unit of measure in your employees.") diff --git a/addons/uom/data/uom_data.xml b/addons/uom/data/uom_data.xml index f929564b1e4..59a2c41208c 100644 --- a/addons/uom/data/uom_data.xml +++ b/addons/uom/data/uom_data.xml @@ -6,18 +6,23 @@ --> Unit + unit Weight + weight Working Time + time Length / Distance + length Volume + volume