From f5a04d5fa1f79e25bed7d9948c99ec4026adc653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 29 Mar 2011 16:09:59 +0200 Subject: [PATCH] Allow to copy project work for issue1807 --- work.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/work.py b/work.py index 24f0b34dca..5adc1348fc 100644 --- a/work.py +++ b/work.py @@ -228,6 +228,27 @@ class Work(ModelSQL, ModelView): return res + def copy(self, ids, default=None): + timesheet_work_obj = self.pool.get('timesheet.work') + + int_id = isinstance(ids, (int, long)) + if int_id: + ids = [ids] + + if default is None: + default = {} + + new_ids = [] + for project_work in self.browse(ids): + timesheet_work_id = timesheet_work_obj.copy(project_work.work.id, + default=default) + pwdefault = default.copy() + pwdefault['work'] = timesheet_work_id + new_ids.append(super(Work, self).copy(project_work.id, + default=pwdefault)) + if int_id: + return new_ids[0] + return new_ids def delete(self, ids): timesheet_work_obj = self.pool.get('timesheet.work')