diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 219b6b266..b6c8fbb3d 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3495,9 +3495,10 @@ class Basket(FullSearch, OwnPerms): def get_write_query_owns(cls, ishtaruser): return Q(user=ishtaruser) - def duplicate(self, ishtaruser=None): + def duplicate(self, label=None, ishtaruser=None): """ Duplicate the basket. Items in basket are copied but not shared users + :param label: if provided use the name :param ishtaruser: if provided an alternate user is used :return: the new basket """ @@ -3506,13 +3507,15 @@ class Basket(FullSearch, OwnPerms): new_item.pk = None if ishtaruser: new_item.user = ishtaruser - label = new_item.label + if not label: + label = new_item.label while self.__class__.objects.filter( label=label, user=new_item.user).count(): label += unicode(_(u" - duplicate")) + new_item.label = label new_item.save() for item in items: - new_item.add(item) + new_item.items.add(item) return new_item |