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 readonly_fields(self): result = ('owed_amount', 'owed_amount_after_payment', 'applied_amount') #在审批完成 if hasattr(self, 'org_obj') and paymentAuditStatus( self.org_obj, ITEM_APPROVED): result = ('company', 'vendor', 'content', 'owed_amount', 'payment_amount', 'owed_amount_after_payment', 'paymentProperty', 'purchase_amount', 'applied_amount', 'purchase_user', 'paymentType', 'payment_user', 'comments') #在审批中 并且是采购部门 elif hasattr( self, 'org_obj' ) and self.org_obj and self.org_obj.is_applied and not paymentAuditStatus( self.org_obj, ITEM_REJECTED) and isGroup(self, PURCHASE_GROUP): result = ('company', 'vendor', 'content', 'owed_amount', 'payment_amount', 'owed_amount_after_payment', 'paymentProperty', 'purchase_amount', 'applied_amount', 'purchase_user', 'paymentType', 'payment_user', 'comments') #在审批中 并且不是采购部门 elif hasattr( self, 'org_obj' ) and self.org_obj and self.org_obj.is_applied and not paymentAuditStatus( self.org_obj, ITEM_REJECTED) and not isGroup( self, PURCHASE_GROUP): result = ('company', 'vendor', 'content', 'owed_amount', 'payment_amount', 'owed_amount_after_payment', 'paymentProperty', 'purchase_amount', 'purchase_user', 'paymentType', 'payment_user', 'comments') return result
def get_list_display(self): list_display = super(DoPayemntAdmin, self).get_list_display() #只有财务部门才能闭合 if isGroup(self, ACCOUNT_GROUP_MANAGER) or isGroup(self, ACCOUNT_GROUP) : list_display.append('closePayment') return list_display
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(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 confirmReceived(self, instance): if not instance.is_received: path = self.request.get_full_path() if path.count('=') > 0: path += '&_submit=%s' % instance.id else: path += '?_submit=%s' % instance.id #只有财务人员才能确认收票 if isGroup(self, ACCOUNT_GROUP_MANAGER) or isGroup(self, ACCOUNT_GROUP): return """ <div class="btn-group export"> <a class="dropdown-toggle btn btn-default btn-sm" data-toggle="dropdown" href="#"> 确认收票<span class="caret"></span> </a> <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> <li><a href="%s"><i class="fa fa-check-square-o"></i> 确认</a></li> </ul> </div> """ % path else: return " " else: return "<i class='fa fa-check-circle text-success' alt='True'> 已收票</i>"
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 confirmReceived(self, instance): if not instance.is_received: path = self.request.get_full_path() if path.count('=') > 0: path += '&_submit=%s' % instance.id else: path += '?_submit=%s' % instance.id #只有财务人员才能确认收票 if isGroup(self, ACCOUNT_GROUP_MANAGER) or isGroup( self, ACCOUNT_GROUP): return """ <div class="btn-group export"> <a class="dropdown-toggle btn btn-default btn-sm" data-toggle="dropdown" href="#"> 确认收票<span class="caret"></span> </a> <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> <li><a href="%s"><i class="fa fa-check-square-o"></i> 确认</a></li> </ul> </div> """ % path else: return " " else: return "<i class='fa fa-check-circle text-success' alt='True'> 已收票</i>"
def get_list_display(self): list_display = super(DoPayemntAdmin, self).get_list_display() #只有财务部门才能闭合 if isGroup(self, ACCOUNT_GROUP_MANAGER) or isGroup( self, ACCOUNT_GROUP): list_display.append('closePayment') return list_display
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 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 exclude(self): #工程人员不能添加预算量 if isGroup(self, PROJECT_GROUP): return ('posted_quantity', 'audit_quantity', 'approval_comments', 'material') else: return ['posted_quantity', 'audit_quantity']
def block_results_bottom_action(self, context, nodes): #工程人员才可以用 下一步操作 if '_rel_document__id__exact' in self.params and self.params[ '_rel_document__id__exact'] and isGroup(self, PROJECT_GROUP): doc = Document.objects.get( id=self.params['_rel_document__id__exact']) url = '/document/document/?_q_=%s' % doc.document_id return "<a class='dropdown-toggle navbar-right btn btn-success' href='%s'>下一步</a>" % url
def get_list_queryset(self): if isGroup(self, PROJECT_GROUP): #包括其他项目负责人申请的要料单 return super(DocumentAdmin, self).get_list_queryset().filter( project__users__in=[self.user]) else: return super(DocumentAdmin, self).get_list_queryset().filter( project__company=self.user.company, document_id__startswith='PM')
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_list_queryset(self): if isGroup(self, PROJECT_GROUP): return super(DocumentLineItemAdmin, self).get_list_queryset().filter(document__user=self.user).order_by('-document__id', "projectMaterial__project__id", "projectMaterial__material__category__name", "projectMaterial__material__name", "projectMaterial__material__specification") else: return super(DocumentLineItemAdmin, self).get_list_queryset().filter(document__project__company = self.user.company).order_by('-document__id', "projectMaterial__project__id", "projectMaterial__material__category__name", "projectMaterial__material__name", "projectMaterial__material__specification")
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 get_list_queryset(self): if isGroup(self, PROJECT_GROUP): return super(DocumentLineItemAdmin, self).get_list_queryset().filter( document__user=self.user).order_by( '-document__id', "projectMaterial__project__id", "projectMaterial__material__category__name", "projectMaterial__material__name", "projectMaterial__material__specification") else: return super( DocumentLineItemAdmin, self).get_list_queryset().filter( document__project__company=self.user.company).order_by( '-document__id', "projectMaterial__project__id", "projectMaterial__material__category__name", "projectMaterial__material__name", "projectMaterial__material__specification")
def readonly_fields(self): result = ('owed_amount', 'owed_amount_after_payment', 'applied_amount') #在审批完成 if hasattr(self, 'org_obj') and paymentAuditStatus(self.org_obj, ITEM_APPROVED): result = ('company', 'vendor', 'content', 'owed_amount', 'payment_amount', 'owed_amount_after_payment', 'paymentProperty', 'purchase_amount', 'applied_amount', 'purchase_user', 'paymentType', 'payment_user', 'comments') #在审批中 并且是采购部门 elif hasattr(self, 'org_obj') and self.org_obj and self.org_obj.is_applied and not paymentAuditStatus(self.org_obj, ITEM_REJECTED) and isGroup(self, PURCHASE_GROUP): result = ('company', 'vendor', 'content', 'owed_amount', 'payment_amount', 'owed_amount_after_payment', 'paymentProperty', 'purchase_amount', 'applied_amount', 'purchase_user', 'paymentType', 'payment_user', 'comments') #在审批中 并且不是采购部门 elif hasattr(self, 'org_obj') and self.org_obj and self.org_obj.is_applied and not paymentAuditStatus(self.org_obj, ITEM_REJECTED) and not isGroup(self, PURCHASE_GROUP): result = ('company', 'vendor', 'content', 'owed_amount', 'payment_amount', 'owed_amount_after_payment', 'paymentProperty', 'purchase_amount', 'purchase_user', 'paymentType', 'payment_user', 'comments') return result
def block_results_bottom_action(self, context, nodes): #工程人员才可以用 下一步操作 if '_rel_document__id__exact' in self.params and self.params['_rel_document__id__exact'] and isGroup(self, PROJECT_GROUP): doc = Document.objects.get(id = self.params['_rel_document__id__exact']) url = '/document/document/?_q_=%s' % doc.document_id return "<a class='dropdown-toggle navbar-right btn btn-success' href='%s'>下一步</a>" % url
def list_editable(self): if isGroup(self, ACCOUNT_GROUP_MANAGER) or isGroup(self, ACCOUNT_GROUP): return ['receive_date',]
def list_editable(self): if isGroup(self, ACCOUNT_GROUP_MANAGER) or isGroup( self, ACCOUNT_GROUP): return [ 'receive_date', ]
def get_list_queryset(self): if isGroup(self, PROJECT_GROUP): #包括其他项目负责人申请的要料单 return super(DocumentAdmin, self).get_list_queryset().filter(project__users__in = [self.user]) else: return super(DocumentAdmin, self).get_list_queryset().filter(project__company = self.user.company, document_id__startswith ='PM')