[FIX] resource: mixin: copy

When copying a record implementing the resource mixin, the linked
resource should be copied too and not shared across the records.

Fixes #20956
opw-781508
This commit is contained in:
Simon Lejeune
2017-11-20 09:19:07 +01:00
committed by Nicolas Martinelli
parent 73e4dacf78
commit d7d9603f1b
+10
View File
@@ -31,6 +31,16 @@ class ResourceMixin(models.AbstractModel):
values['resource_id'] = resource.id
return super(ResourceMixin, self).create(values)
@api.multi
def copy_data(self, default=None):
if default is None:
default = {}
resource = self.resource_id.copy()
default['resource_id'] = resource.id
default['company_id'] = resource.company_id.id
default['resource_calendar_id'] = resource.calendar_id.id
return super(ResourceMixin, self).copy_data(default)
def get_work_days_count(self, from_datetime, to_datetime, calendar=None):
""" Return the number of work days for the resource, taking into account
leaves. An optional calendar can be given in case multiple calendars can