Untitled
def create_fresh_order_with_items(self, items=[], warehouse: Warehouse = Warehouse_9833, is_express=False, ts_delay=20, client_id=None, order_qty=1, items_qty=1, with_bag=False, timeslot=0, ts_source: TsSource = TsSource.metatarificator) -> List[KrakenOrder]: if timeslot == 0: lat, lon = self.timeslotmanager.get_coordinates_by_str_address(warehouse.address) address = Address(warehouse.address, lat, lon) if is_express: timeslot = self.get_timeslot(warehouse, TsType.express, ts_delay, ts_source, address) else: timeslot = self.get_timeslot(warehouse, TsType.regular, ts_delay, ts_source, address) fresh_orders = [] client = User(id=client_id, phone='0', token='0') if not client_id or client_id == 'false': client = self.userhelper.create_user(with_phone=True) item_list = [] for item in items: item = Item(item, items_qty, DimensionsValues.foot_dimension) item_list.append(item) if not items: item_list = self.itemmanager.get_supermarket_item(warehouse, unique_qty=1, qty=items_qty) if with_bag: item_list.append(Item("519413018", items_qty, DimensionsValues.foot_dimension)) for i in range(order_qty): posting1 = Posting(address, item_list, timeslot, warehouse) kr_order = KrakenOrder(postings=[posting1], warehouse=warehouse, client=client) fresh_order = KrakenOrder().prepare_body(kr_order) fresh_orders.append(deepcopy(fresh_order)) print(fresh_orders) return fresh_orders @whc.post('/create_oms_order') def create_oms_order(wh_rezon_id: int, item_id: int, client_id: int = 0, delivery_type: OrderType = OrderType.mono_day_to_day, with_bag: bool = False, postings_qty: int = 1, item_qty: int = 1, timeslot_id: int = 0 ): if client_id == 0: client_id = random.randint(1000000, 9999999) body_function = order_types_mapper.get(delivery_type) response = create_and_pay(body_function(client_id, wh_rezon_id, item_id, with_bag, item_qty, timeslot_id), postings_qty ) return response
Leave a Comment