Beispiel #1
0
def stock_transfer():
    """ """

    bag = bag_utils.is_modifiable_bag(session.current_bag)

    # check if all the bag items are consistent
    bag_items = db(db.bag_item.id_bag == bag.id).select()
    # delete the bag if there are no items
    if not bag_items:
        session.flash = T('There are no items in the bag')
        redirection()

    # counts services, since services cant be transfered
    count = 0
    for bag_item in bag_items:
        if not bag_item.id_item.has_inventory:
            count += 1

    # the bag contains services
    if count:
        session.flash = T('You should not be transfering services')
        bag_utils.auto_bag_selection()
        redirect(URL('default', 'index'))

    bag_utils.check_bag_items_integrity(bag_items)

    # create stock transfer record
    new_stock_transfer_id = db.stock_transfer.insert(id_store_from=bag.id_store.id, id_bag=bag.id)
    bag.status = BAG_COMPLETE
    bag.update_record()
    item_utils.remove_stocks(bag_items)

    redirect(URL('stock_transfer', 'ticket', args=new_stock_transfer_id))
Beispiel #2
0
def stock_transfer():
    """ """

    bag = bag_utils.is_modifiable_bag(session.current_bag)

    # check if all the bag items are consistent
    bag_items = db(db.bag_item.id_bag == bag.id).select()
    # delete the bag if there are no items
    if not bag_items:
        session.flash = T('There are no items in the bag')
        redirection()

    # counts services, since services cant be transfered
    count = 0
    for bag_item in bag_items:
        if not bag_item.id_item.has_inventory:
            count += 1

    # the bag contains services
    if count:
        session.flash = T('You should not be transfering services')
        bag_utils.auto_bag_selection()
        redirect(URL('default', 'index'))

    bag_utils.check_bag_items_integrity(bag_items)

    # create stock transfer record
    new_stock_transfer_id = db.stock_transfer.insert(id_store_from=bag.id_store.id, id_bag=bag.id)
    bag.status = BAG_COMPLETE
    bag.update_record()
    item_utils.remove_stocks(bag_items)

    redirect(URL('stock_transfer', 'ticket', args=new_stock_transfer_id))
Beispiel #3
0
def deliver(sale):
    """ Sets the sale as delivered, removing its items from the stock """

    db = current.db

    bag_items = db(db.bag_item.id_bag == sale.id_bag.id).iterselect()
    item_utils.remove_stocks(bag_items)
    create_sale_event(sale, SALE_DELIVERED)
    sale.update_record()
def deliver(sale):
    """ Sets the sale as delivered, removing its items from the stock """


    db = current.db

    bag_items = db(db.bag_item.id_bag == sale.id_bag.id).iterselect()
    item_utils.remove_stocks(bag_items)
    create_sale_event(sale, SALE_DELIVERED)
    sale.update_record()
Beispiel #5
0
def create():
    """
        args: [id_bag]
    """

    bag = get_valid_bag(request.args(0))
    if not bag:
        session.info = T('Bag not found')
        redirection()
    bag_only_items_list = True
    include_bag = False

    bag_items = db(db.bag_item.id_bag == bag.id).select()
    bag_items_count = len(bag_items)
    for bag_item in bag_items:
        qty = item_stock_qty(bag_item.id_item, bag.id_store)
        bag_item.quantity = min(bag_item.quantity, qty)
        if not bag_item.quantity or not bag_item.id_item.has_inventory:
            bag_item.delete_record()
            bag_items_count -= 1
        else:
            bag_item.update_record()
    refresh_bag_data(bag.id)

    if not bag_items_count:
        session.info = T('Please add items to the product loss')
        redirection()

    form = SQLFORM(db.product_loss,
                   buttons=[
                       INPUT(_type='submit',
                             _value=T('Commit'),
                             _class="btn btn-primary"),
                       A(T('Cancel'),
                         _class='btn btn-default',
                         _href=URL('default', 'index'))
                   ],
                   _id="product_loss_form",
                   formstyle='bootstrap3_inline')
    form.vars.id_bag = bag.id
    form.vars.id_store = bag.id_store.id

    if form.process().accepted:
        bag.status = BAG_COMPLETE
        bag.update_record()
        remove_stocks(bag_items)
        session.info = T('Product loss commited')
        redirection()
    elif form.errors:
        session.info = T('Form has errors')

    return locals()
def create():
    """
        args: [id_bag]
    """

    bag = get_valid_bag(request.args(0))
    if not bag:
        session.info = T('Bag not found')
        redirection()
    bag_only_items_list = True
    include_bag = False

    bag_items = db(db.bag_item.id_bag == bag.id).select()
    bag_items_count = len(bag_items)
    for bag_item in bag_items:
        qty = item_stock_qty(bag_item.id_item, bag.id_store)
        bag_item.quantity = min(bag_item.quantity, qty)
        if not bag_item.quantity or not bag_item.id_item.has_inventory:
            bag_item.delete_record()
            bag_items_count -= 1
        else:
            bag_item.update_record()
    refresh_bag_data(bag.id)

    if not bag_items_count:
        session.info = T('Please add items to the product loss')
        redirection()

    form = SQLFORM(db.product_loss, buttons=[INPUT(_type='submit', _value=T('Commit'), _class="btn btn-primary"), A(T('Cancel'), _class='btn btn-default', _href=URL('default', 'index')) ], _id="product_loss_form", formstyle='bootstrap3_inline')
    form.vars.id_bag = bag.id
    form.vars.id_store = bag.id_store.id

    if form.process().accepted:
        bag.status = BAG_COMPLETE
        bag.update_record()
        remove_stocks(bag_items)
        session.info = T('Product loss commited')
        redirection()
    elif form.errors:
        session.info = T('Form has errors')

    return locals()