diff options
| author | Jorge Pinna Puissant <jpp@odoo.com> | 2020-04-29 12:59:40 +0000 |
|---|---|---|
| committer | Jorge Pinna Puissant <jpp@odoo.com> | 2020-04-30 13:53:17 +0000 |
| commit | ed5ab19065767156802fb2a148636ae0c6bbd017 (patch) | |
| tree | 6939818c766a991a0f731c851fda9711156da367 /addons/resource/models | |
| parent | 3e81b810aaaaa29c10c57e092fb037b92f5f6e75 (diff) | |
[FIX] resource: week_type for new periods
In a calendar with 2 weeks mode (odd and even), before this commit, all
new created periods (placed in one of the two sections) don't have the
week_type field set. This generates a confusion, because a period that
should be applied only in odd weeks, for instance, it was applied also
in the even weeks.
Now, the new periods will have the week_type field set with the
week_type of the section where is it. Also, an error message is raised
if a period is not in one of the two sections.
opw-2239966
closes odoo/odoo#50478
X-original-commit: 33a62118818952872321591e85403b657380128a
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
Diffstat (limited to 'addons/resource/models')
| -rw-r--r-- | addons/resource/models/resource.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/addons/resource/models/resource.py b/addons/resource/models/resource.py index daf16b47e16..fb79c8819ae 100644 --- a/addons/resource/models/resource.py +++ b/addons/resource/models/resource.py @@ -204,6 +204,14 @@ class ResourceCalendar(models.Model): default.update(name=_('%s (copy)') % (self.name)) return super(ResourceCalendar, self).copy(default) + @api.constrains('attendance_ids') + def _check_attendance_ids(self): + for resource in self: + if (resource.two_weeks_calendar and + resource.attendance_ids.filtered(lambda a: a.display_type == 'line_section') and + not resource.attendance_ids.sorted('sequence')[0].display_type): + raise ValidationError(_("In a calendar with 2 weeks mode, all periods need to be in the sections.")) + @api.depends('two_weeks_calendar') def _compute_two_weeks_explanation(self): today = fields.Date.today() |
