def __unicode__(self): from psi.app.utils import user_has_role result = self.name if user_has_role('supplier_view'): result += "/供应商:{0}".format(self.supplier.name[:6]) if (user_has_role('purchase_price_view') and current_user.organization.type.code == const.DIRECT_SELLING_STORE_ORG_TYPE_KEY): result += "/进货价:{0}".format(self.purchase_price) result += '/零售价:{0}'.format(self.retail_price) elif (user_has_role('purchase_price_view') and current_user.organization.type.code == const.FRANCHISE_STORE_ORG_TYPE_KEY): result += "/拿货价:{0}".format(self.franchise_price) result += '/建议零售价:{0}'.format(self.retail_price) return result
def inventory_transaction_formatter(view, context, model, name): s = model.inventory_transaction if s is not None: if user_has_role('purchase_price_view'): fields = ( date_field, type_field, total_amount_field, remark_field, ) detail_fields = (product_field, in_transit_quantity_field, quantity_field, price_field, total_amount_field, remark_field) else: fields = ( date_field, type_field, remark_field, ) detail_fields = (product_field, in_transit_quantity_field, quantity_field, remark_field) return _obj_formatter(view, context, model, value=s, model_name='inventorytransaction', title=str(s.id), fields=fields, detail_fields=detail_fields, detail_field='lines') return ''
def receivings_formatter(view, context, model, name): if hasattr(model, 'po_receivings'): receivings = model.po_receivings elif hasattr(model, 'it_receiving'): receivings = [model.it_receiving] else: receivings = [model.po_receivings] if user_has_role('purchase_price_view'): fields = ( date_field, total_amount_field, status_field, remark_field, ) detail_fields = (product_field, quantity_field, price_field, total_amount_field) else: fields = ( date_field, status_field, remark_field, ) detail_fields = (product_field, quantity_field) return _objs_formatter(view, context, model, values=receivings, model_name='receiving', fields=fields, detail_field='lines', detail_fields=detail_fields)
def decorated_function(*args, **kwargs): if current_user.is_authenticated: from psi.app.utils import user_has_role return f(*args, **kwargs) if user_has_role( expect_role) else action_on_error() else: return action_on_error()
def __unicode__(self): if self.type.code == const.DIRECT_PO_TYPE_KEY: s = str(self.supplier.name) else: s = str(self.organization.name) result = "{0}/{1}/{2}/{3}".format(str(self.id), s, str(self.order_date), self.status.display) if user_has_role('purchase_price_view'): result += "/" + str(self.total_amount) return result
def inventory_transaction_formatter(view, context, model, name): s = model.inventory_transaction if s is not None: if user_has_role('purchase_price_view'): fields = (date_field, type_field, total_amount_field, remark_field,) detail_fields = (product_field, in_transit_quantity_field, quantity_field, price_field, total_amount_field, remark_field) else: fields = (date_field, type_field, remark_field,) detail_fields = (product_field, in_transit_quantity_field, quantity_field, remark_field) return _obj_formatter(view, context, model, value=s, model_name='inventorytransaction', title=str(s.id), fields=fields, detail_fields=detail_fields, detail_field='lines') return ''
def purchase_order_formatter(view, context, model, name): s = model.purchase_order if s is not None: if user_has_role('purchase_price_view'): fields = (order_type_field, order_status_field, order_date_field, supplier_field, goods_amount_field, total_amount_field, remark_field) detail_fields = (product_field, quantity_field, unit_price_field, total_amount_field) else: fields = (order_type_field, order_status_field, order_date_field, supplier_field, remark_field) detail_fields = (product_field, quantity_field) return _obj_formatter(view, context, model, value=s, model_name='purchaseorder', title=str(s.id), fields=fields, detail_fields=detail_fields, detail_field='lines') return ''
def receivings_formatter(view, context, model, name): if hasattr(model, 'po_receivings'): receivings = model.po_receivings elif hasattr(model, 'it_receiving'): receivings = [model.it_receiving] else: receivings = [model.po_receivings] if user_has_role('purchase_price_view'): fields = (date_field, total_amount_field, status_field, remark_field,) detail_fields = (product_field, quantity_field, price_field, total_amount_field) else: fields = (date_field, status_field, remark_field,) detail_fields = (product_field, quantity_field) return _objs_formatter(view, context, model, values=receivings, model_name='receiving', fields=fields, detail_field='lines', detail_fields=detail_fields)
def __unicode__(self): result = '产品:{0}/数量:{1}'.format(str(self.product.name), str(self.quantity)) if user_has_role('purchase_price_view'): result += "/价格:{0}".format(str(self.unit_price)) return result
def decorated_function(*args, **kwargs): if current_user.is_authenticated: from psi.app.utils import user_has_role return f(*args, **kwargs) if user_has_role(expect_role) else action_on_error() else: return action_on_error()