diff options
Diffstat (limited to 'ishtar/ishtar_base/models.py')
-rw-r--r-- | ishtar/ishtar_base/models.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ishtar/ishtar_base/models.py b/ishtar/ishtar_base/models.py index ee22b9973..af1d38f05 100644 --- a/ishtar/ishtar_base/models.py +++ b/ishtar/ishtar_base/models.py @@ -994,6 +994,18 @@ class Item(BaseHistorizedItem, OwnPerms): dating = models.ForeignKey(Dating, verbose_name=_(u"Dating")) history = HistoricalRecords() + def duplicate(self, user): + dct = dict([(attr, getattr(self, attr)) for attr in ('order', 'label', + 'description', 'material_type', 'volume', 'weight', + 'item_number', 'dating')]) + dct['order'] += 1 + dct['history_modifier'] = user + new = self.__class__(**dct) + new.save() + for base_item in self.base_items.all(): + new.base_items.add(base_item) + return new + class Meta: verbose_name = _(u"Item") verbose_name_plural = _(u"Items") @@ -1143,9 +1155,8 @@ class Container(LightHistorizedItem): verbose_name_plural = _(u"Containers") def __unicode__(self): - lbl = self.reference - lbl += u" - %s" % unicode(self.container_type) - lbl += u" (%s)" % unicode(self.location) + lbl = u" - ".join((self.reference, unicode(self.container_type), + unicode(self.location))) return lbl if settings.COUNTRY == 'fr': |