Skip to content

Commit

Permalink
Merge PR #514 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by huguesdk
  • Loading branch information
github-grap-bot committed Jun 20, 2023
2 parents b7b2cc4 + 4cb8e84 commit 4a37e47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions shift/models/cooperative_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ def _compute_status(self):

@api.constrains("working_mode", "irregular_start_date")
def _constrains_irregular_start_date(self):
if self.working_mode == "irregular" and not self.irregular_start_date:
raise UserError(_("Irregular workers must have an irregular start date."))
for status in self:
if status.working_mode == "irregular" and not status.irregular_start_date:
raise UserError(
_("Irregular workers must have an irregular start date.")
)

def _get_watched_fields(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions shift/newsfragments/514.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed a bug where writing to multiple cooperative.status records simultaneously
caused a singleton error. Writing to multiple records simultaneously is now
possible.
9 changes: 9 additions & 0 deletions shift/tests/test_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,3 +505,12 @@ def test_unsubscribe_worker_from_task_template_computes_next_shift(self):
self.worker_regular_1.cooperative_status_ids.next_shift_id,
next_shift,
)

def test_write_multiple_statuses(self):
"""A naïve test that verifies that the write function on multiple status
records doesn't result in an error.
"""
statuses = self.env["cooperative.status"]
statuses |= self.worker_regular_1.cooperative_status_ids
statuses |= self.worker_irregular_2.cooperative_status_ids
statuses.write({"irregular_start_date": "2023-05-08"})

0 comments on commit 4a37e47

Please sign in to comment.