def get_customer_shipments():
    d = datetime.utcnow() - timedelta(days=1)
    filter_ = [
        'AND',
        [
            "create_date", ">", {
                "__class__": "datetime",
                "year": d.year,
                "month": d.month,
                "day": d.day,
                "hour": d.hour,
                "minute": d.minute,
                "second": d.second,
                "microsecond": 0
            }
        ],
    ]
    # filter_ = ['AND', ['id', '=', 50981]]
    fields = [
        'sales', 'shipping_instructions', 'rec_name', 'warehouse',
        'contents_explanation', 'order_numbers'
    ]
    Shipment = client.model('stock.shipment.out')
    shipments = Shipment.search_read_all(domain=filter_,
                                         order=None,
                                         fields=fields)
    return list(shipments)
Esempio n. 2
0
def lost_orders(prod):
    shopify_quantities = {}
    for item in prod:
        for v in item['variants']:
            shopify_quantities[v['sku']] = {
                'inventory_quantity': v['inventory_quantity'],
                'shopify_product_id': item['id'],
                'shopify_variant_id': v['id']
            }

    lost_sku = list(shopify_quantities.keys())

    Model = client.model('product.product')
    fields = ["id", "code", "quantity_available"]
    products = Model.search_read_all(
        domain=["AND",["code","in", lost_sku],],
        order=None,
        fields=fields,
    )
    products = list(products)

    for p in products:
        p['shopify_quantity'] = shopify_quantities[p['code']]['inventory_quantity']
        p['difference'] = int(p['shopify_quantity']) - int(p['quantity_available'])

        p['shopify_product_id'] = shopify_quantities[p['code']]['shopify_product_id']
        p['shopify_variant_id'] = shopify_quantities[p['code']]['shopify_variant_id']

    products = list(filter(lambda x: bool(x['difference']), products))

    return products
Esempio n. 3
0
def get_sales(ids):
    Sale = client.model('sale.sale')
    fields = ['number', 'lines', 'reference', 'shipping_instructions']
    sales = Sale.search_read_all(domain=[["AND", ['id', 'in', ids]]],
                                 order=None,
                                 fields=fields)
    return list(sales)
def get_sales_by_ids(ids):
    filter_ = [
        'AND',
        ["id", "in", ids],
    ]
    fields = ['total_amount']
    Sale = client.model('sale.sale')
    sales = Sale.search_read_all(domain=filter_, order=None, fields=fields)
    return list(sales)
Esempio n. 5
0
def get_order_lines(ids):
    Line = client.model('sale.line')
    fields = [
        'note', 'product', 'quantity', 'product.code', 'note',
        'product.quantity_available', 'metadata', 'product.rec_name'
    ]
    lines = Line.search_read_all(domain=['AND', ['id', 'in', ids]],
                                 order=None,
                                 fields=fields)
    lines = list(lines)
    # self.mark_engraving_lines(lines)
    # self.mark_bundle_lines(lines)
    return list(lines)
Esempio n. 6
0
def new_inventory(for_update, warehouse):
    # create inventory record in fullfill
    lines = [{'product': i['_id'], 'quantity': i['_to']} for i in for_update]
    params = [
        {
            'date': client.today(),
            'type': 'cycle',
            'lost_found': 7,
            'location': warehouse,
            'lines': [['create', lines]],
        }
    ]

    stock_inventory = client.model('stock.inventory')
    res = stock_inventory.create(params)
    return res
Esempio n. 7
0
def confirm_inventory(inventory):
    # confirm inventory record in fullfill (this apply changes)
    IA = client.model('stock.inventory')
    return IA.confirm(inventory)
Esempio n. 8
0
def complete_inventory(inventory):
    # complete inventory record in fullfill
    IA = client.model('stock.inventory')
    return IA.complete(inventory)
def update_shipment(shipment, changes):
    model = client.model('stock.shipment.out')
    model.write([shipment['id']], changes)
Esempio n. 10
0
def update_shipment(shipment, context):
    Model = client.model('stock.shipment.out')
    url = Model.path + f'/{shipment["id"]}'
    response = requests.put(url, json=context, headers=headers)
    if response.status_code == 200:
        return True