Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] resource_work_time_from_contracts: remove readonly #312

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions resource_work_time_from_contracts/models/resource_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions resource_work_time_from_contracts/models/resource_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading