From 5a470da62ecb1bdbf7ba0afd04c620e6e77878d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 11 May 2009 19:22:34 +0200 Subject: [PATCH] Prepare changelog for release 1.0.4 --- CHANGELOG | 3 +++ location.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 72ad7b86b5..9e3e2698e3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +Version 1.0.4 - 2009-05-11 +* Some bug fixes (see mercurial logs for details) + Version 1.0.3 - 2009-03-02 * Some bug fixes (see mercurial logs for details) diff --git a/location.py b/location.py index 8615117115..057e7f2a75 100644 --- a/location.py +++ b/location.py @@ -209,10 +209,56 @@ class Location(OSV): def copy(self, cursor, user, ids, default=None, context=None): if default is None: default = {} + int_id = False + if isinstance(ids, (int, long)): + int_id = True + ids = [ids] + default['left'] = 0 default['right'] = 0 - return super(Location, self).copy(cursor, user, ids, default=default, - context=context) + + res = [] + locations = self.browse(cursor, user, ids, context=context) + for location in locations: + if location.type == 'warehouse': + + wh_default = default.copy() + wh_default['type'] = 'view' + wh_default['input_location'] = False + wh_default['output_location'] = False + wh_default['storage_location'] = False + wh_default['childs'] = False + + new_id = super(Location, self).copy( + cursor, user, location.id, default=wh_default, + context=context) + + child_context = context and context.copy() or {} + child_context['cp_warehouse_locations'] = { + 'input_location': location.input_location.id, + 'output_location': location.output_location.id, + 'storage_location': location.storage_location.id} + child_context['cp_warehouse_id'] = new_id + + self.copy( + cursor, user, [c.id for c in location.childs], + default={'parent':new_id}, context=child_context) + self.write( + cursor, user, new_id, {'type': 'warehouse'}, context=context) + else: + new_id = super(Location, self).copy( + cursor, user, location.id, default=default, context=context) + warehouse_locations = context.get('cp_warehouse_locations', {}) + if location.id in warehouse_locations.values(): + for field, loc_id in warehouse_locations.iteritems(): + if loc_id == location.id: + self.write( + cursor, user, context['cp_warehouse_id'], + {field: new_id}, context=context) + + res.append(new_id) + + return int_id and res[0] or res Location()