diff --git a/resource_work_time_from_contracts/models/resource_calendar_leaves.py b/resource_work_time_from_contracts/models/resource_calendar_leaves.py index a2483761b..25437cb17 100644 --- a/resource_work_time_from_contracts/models/resource_calendar_leaves.py +++ b/resource_work_time_from_contracts/models/resource_calendar_leaves.py @@ -13,6 +13,9 @@ class ResourceCalendarLeaves(models.Model): # leaves for all resources are defined in the same resource calendar, # which is needed to compute working hours while taking leaves into # account. + # fixme A readonly related field without an inverse method should not have a + # default value, as it does not make sense. + # cf odoo/odoo/fields.py:626 calendar_id = fields.Many2one( "resource.calendar", related="resource_id.calendar_id", diff --git a/resource_work_time_from_contracts/models/resource_mixin.py b/resource_work_time_from_contracts/models/resource_mixin.py index 442869f61..e2daf482b 100644 --- a/resource_work_time_from_contracts/models/resource_mixin.py +++ b/resource_work_time_from_contracts/models/resource_mixin.py @@ -6,7 +6,7 @@ from pytz import timezone, utc -from odoo import fields, models +from odoo import models from odoo.tools import float_utils from odoo.addons.resource.models.resource import ROUNDING_FACTOR @@ -16,9 +16,6 @@ class ResourceMixin(models.AbstractModel): _inherit = "resource.mixin" - # make this field read-only. - resource_calendar_id = fields.Many2one("resource.calendar", readonly=True) - def list_work_time_per_day( self, from_datetime, diff --git a/resource_work_time_from_contracts/models/resource_resource.py b/resource_work_time_from_contracts/models/resource_resource.py index 134f6934a..6870149ec 100644 --- a/resource_work_time_from_contracts/models/resource_resource.py +++ b/resource_work_time_from_contracts/models/resource_resource.py @@ -9,6 +9,10 @@ class ResourceResource(models.Model): _inherit = "resource.resource" # force this field to be equal to the resource_calendar_id of the company. + # fixme A readonly related field without an inverse method should not have a + # default value, as it does not make sense. + # cf odoo/odoo/fields.py:626 + calendar_id = fields.Many2one( "resource.calendar", related="company_id.resource_calendar_id",