From c996469e842ef3541f5b1290d2541dd6d2f2844e Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 3 Sep 2020 12:30:35 +0200 Subject: Document QA: packaging - fix QA for search and edit --- ishtar_common/models.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index d9112b5e7..42b4c479a 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -5633,8 +5633,13 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel, QuickAction( url="document-qa-duplicate", icon_class="fa fa-clone", text=_("Duplicate"), target="one", - rights=['change_document', - 'change_own_document']), + rights=['change_document', 'change_own_document']), + QuickAction( + url="document-qa-packaging", icon_class="fa fa-gift", + text=_("Packaging"), target="many", + rights=['change_document', 'change_own_document'], + module='warehouse' + ), ] SERIALIZATION_FILES = ["image", "thumbnail", "associated_file"] @@ -5795,11 +5800,18 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel, # is_locked = self.is_locked(request.user) can_edit_document = self.can_do(request, 'change_document') - if can_edit_document: - actions += [ - (reverse("document-qa-duplicate", args=[self.pk]), - _("Duplicate"), "fa fa-clone", "", "", True), - ] + if not can_edit_document: + return actions + actions += [ + (reverse("document-qa-duplicate", args=[self.pk]), + _("Duplicate"), "fa fa-clone", "", "", True), + ] + if get_current_profile().warehouse: + actions.append( + (reverse("document-qa-packaging", args=[self.pk]), + _("Packaging"), + "fa fa-gift", "", "", True) + ) return actions @property -- cgit v1.2.3