def get_list_display(self): list_display = super(DocumentLineItemAdmin, self).get_list_display() #工程人员不能看到预算量 isProjectGroup = isGroup(self, PROJECT_GROUP) if isProjectGroup: if 'getQuantity' in list_display: list_display.remove('getQuantity') isApproved = False if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: if (item.status == ITEM_APPROVED): isApproved = True #已修改审批结束或是采购部门才可以修改实际采购材料 if not (isApproved or isGroup(self, PURCHASE_GROUP)): if 'material' in list_display: list_display.remove('material') #审批结束没有结束 不用显示 已采购量, 已到货数量 if not isApproved: if 'getTotalPurchasedQuantity' in list_display: list_display.remove('getTotalPurchasedQuantity') if 'posted_quantity' in list_display: list_display.remove('posted_quantity') if isProjectGroup: if 'audit_quantity' in list_display: list_display.remove('audit_quantity') if 'approval_comments' in list_display: list_display.remove('approval_comments') return list_display
def actions(self): actions = [] #闭合的采购单不能再被修改 if "close" in self.request.GET: order_id = self.request.GET['close'] if is_closed(order_id): return actions if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: document = Document.objects.get(id=document_id) if (item.status == ITEM_REJECTED) and isGroup( self, PROJECT_GROUP): actions.append(BatchChangeAction) if (item.status == ITEM_APPROVED) and isGroup( self, PURCHASE_GROUP) and ( document and not isPurchCompleted(document)): actions.append(PurchaseOrderSelectedAction) else: if isGroup(self, PROJECT_GROUP): actions.append(BatchChangeAction) return actions
def list_editable(self): if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: document = Document.objects.get(id=document_id) #自己已经审批通过不能再修改 if hasApprovedBySelf(self, item): return [] #采购部门可以修改实际采购名称 if (item.status == ITEM_APPROVED): if isGroup(self, PURCHASE_GROUP) and ( document and not isPurchCompleted(document)): return ['material'] else: return [] if (item.status == ITEM_REJECTED) and isGroup( self, PROJECT_GROUP): return [ 'expected_date', 'expected_quantity', 'brand', 'comments' ] if canEditAuditQty(self): return [ 'expected_date', 'audit_quantity', 'approval_comments' ] else: if isGroup(self, PROJECT_GROUP): return [ 'expected_date', 'expected_quantity', 'brand', 'comments' ]
def list_editable(self): if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: document = Document.objects.get(id = document_id) #自己已经审批通过不能再修改 if hasApprovedBySelf(self, item): return [] #采购部门可以修改实际采购名称 if (item.status == ITEM_APPROVED): if isGroup(self, PURCHASE_GROUP) and (document and not isPurchCompleted(document)): return ['material'] else: return [] if (item.status == ITEM_REJECTED) and isGroup(self, PROJECT_GROUP): return ['expected_date', 'expected_quantity', 'brand','comments'] if canEditAuditQty(self): return ['expected_date', 'audit_quantity', 'approval_comments'] else: if isGroup(self, PROJECT_GROUP): return ['expected_date', 'expected_quantity', 'brand', 'comments']
def get_list_display_links(self): list_display_links = super(DocumentLineItemAdmin, self).get_list_display_links() if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: if (item.status != ITEM_REJECTED): list_display_links = ('none') else: list_display_links = ('none') return list_display_links
def get_actions(self): actions = super(DocumentLineItemAdmin, self).get_actions() if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: if (item.status == ITEM_REJECTED) and isGroup(self, PROJECT_GROUP): actions.append(BatchChangeAction) else: if isGroup(self, PROJECT_GROUP): actions.append(BatchChangeAction) return actions
def batch_fields(self): if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: if (item.status == ITEM_APPROVED): return [] if (item.status == ITEM_REJECTED) and isGroup(self, PROJECT_GROUP): return ['expected_date', ] else: if isGroup(self, PROJECT_GROUP): return ['expected_date', ]
def get_actions(self): actions = super(DocumentLineItemAdmin, self).get_actions() if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: if (item.status == ITEM_REJECTED) and isGroup( self, PROJECT_GROUP): actions.append(BatchChangeAction) else: if isGroup(self, PROJECT_GROUP): actions.append(BatchChangeAction) return actions
def batch_fields(self): if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: if (item.status == ITEM_APPROVED): return [] if (item.status == ITEM_REJECTED) and isGroup( self, PROJECT_GROUP): return [ 'expected_date', ] else: if isGroup(self, PROJECT_GROUP): return [ 'expected_date', ]
def actions(self): actions=[] #闭合的采购单不能再被修改 if "close" in self.request.GET: order_id = self.request.GET['close'] if is_closed(order_id): return actions if "_rel_document__id__exact" in self.request.GET: document_id = self.request.GET['_rel_document__id__exact'] item = getItem(document_id) if item is not None: document = Document.objects.get(id = document_id) if (item.status == ITEM_REJECTED) and isGroup(self, PROJECT_GROUP): actions.append(BatchChangeAction) if (item.status == ITEM_APPROVED) and isGroup(self, PURCHASE_GROUP) and (document and not isPurchCompleted(document)): actions.append(PurchaseOrderSelectedAction) else: if isGroup(self, PROJECT_GROUP): actions.append(BatchChangeAction) return actions