Пример #1
0
 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
Пример #2
0
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 ''
Пример #3
0
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)
Пример #4
0
 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()
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
 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
Пример #8
0
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 ''
Пример #9
0
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 ''
Пример #10
0
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)
Пример #11
0
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 ''
Пример #12
0
 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
Пример #13
0
 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()
Пример #14
0
 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