Skip to content

Commit

Permalink
[FIX] resource: Improve calendar duplicate
Browse files Browse the repository at this point in the history
Purpose
=======

When duplicating a calendar, duplicate their global time off too.

closes odoo#49133

Taskid: 2230549
Signed-off-by: Yannick Tivisse (yti) <[email protected]>
  • Loading branch information
tivisse committed Apr 8, 2020
1 parent 962a3e3 commit 445621c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion addons/resource/models/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def default_get(self, fields):
'resource.calendar.leaves', 'calendar_id', 'Time Off')
global_leave_ids = fields.One2many(
'resource.calendar.leaves', 'calendar_id', 'Global Time Off',
domain=[('resource_id', '=', False)]
domain=[('resource_id', '=', False)], copy=True,
)
hours_per_day = fields.Float("Average Hour per Day", default=HOURS_PER_DAY,
help="Average hours per day a resource is supposed to work with this calendar.")
Expand All @@ -195,6 +195,15 @@ def default_get(self, fields):
two_weeks_calendar = fields.Boolean(string="Calendar in 2 weeks mode")
two_weeks_explanation = fields.Char('Explanation', compute="_compute_two_weeks_explanation")

@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
if default is None:
default = {}
if not default.get('name'):
default.update(name=_('%s (copy)') % (self.name))
return super(ResourceCalendar, self).copy(default)

@api.depends('two_weeks_calendar')
def _compute_two_weeks_explanation(self):
today = fields.Date.today()
Expand Down

0 comments on commit 445621c

Please sign in to comment.