コード例 #1
0
    def moveStock(self, lista, carro, id_bodega, order_id):

        for l in lista:

            if len(carro) > 0:
                cart = Cart()
                cart.id = l["id"]
                cart.Remove()

                kardex = Kardex()

                producto = Product()
                response = producto.InitById(l["product_id"])

                if "success" in response:

                    kardex.product_sku = producto.sku
                    kardex.cellar_identifier = id_bodega
                    kardex.operation_type = Kardex.OPERATION_MOV_OUT
                    kardex.sell_price = l['price']
                    kardex.order_id = order_id

                    _s = Size()
                    _s.name = l["size"]
                    res_name = _s.initByName()

                    if "success" in res_name:
                        kardex.size_id = _s.id
                    elif debugMode:
                        print res_name["error"]

                    kardex.date = str(
                        datetime.now(
                            pytz.timezone('Chile/Continental')).isoformat())
                    kardex.user = "******"
                    kardex.units = l["quantity"]
                    kardex.price = producto.price

                    kardex.Insert()

                    c = Cellar()
                    res_reservation = c.GetReservationCellar()

                    reservation_cellar = shipping_cellar

                    if "success" in res_reservation:
                        reservation_cellar = res_reservation["success"]
                    elif debugMode:
                        print res_reservation["error"]

                    kardex.cellar_identifier = reservation_cellar
                    kardex.operation_type = Kardex.OPERATION_MOV_IN

                    res_kardex = kardex.Insert()

                    if debugMode and "error" in res_kardex:
                        print res_kardex["error"]

                elif debugMode:
                    print response["error"]
コード例 #2
0
    def get(self):

        cart = Cart()
        cart.id = self.get_argument("cart_id", "")
        if cart.id == "":
            self.write("No existe el item a eliminar")
        else:
            response_obj = cart.Remove()
            if "success" in response_obj:
                self.write("ok")
            else:
                self.write(response_obj["error"])