def test_can_be_created(self): submissions = feeds_gw.submit_product_feed( products=[self.product], marketplaces=[self.marketplace]) self._wait_until_submission_processed(submissions[0]) submission = feeds_gw.switch_product_fulfillment( marketplace=self.marketplace, products=[self.product]) self._wait_until_submission_processed(submission) creator = FulfillmentOrderCreator() orders = creator.create_fulfillment_order(self.order)
def setUp(self): super(TestUpdatingFulfillmentOrders, self).setUp() self.merchant = factories.MerchantAccountFactory() self.order = factories.OrderFactory() factories.OrderLineFactory( order=self.order, product__amazon_profile__sku='SOME-SELLER-SKU') creator = FulfillmentOrderCreator() self.fulfillment_order = creator.create_fulfillment_order( self.order)[0]
def setUp(self): super(TestFulfillmentShipmentCreator, self).setUp() self.merchant = factories.MerchantAccountFactory() self.creator = FulfillmentOrderCreator() self.address = ShippingAddress.objects.create( first_name='test', last_name='man', line1="123 Imanginary Ave", line4="Funky Town", state="CA", postcode="56789", country=Country.objects.all()[0], ) self.basket = factories.BasketFactory() self.basket.add_product(factories.ProductFactory()) self.basket.add_product(factories.ProductFactory())
def submit_order_to_mws(order, user, **kwargs): if kwargs.get('raw', False): return # these modules have to be imported here because they rely on loading # models from oscar_mws using get_model which are not fully loaded at this # point because the receivers module is imported into models.py from oscar_mws.fulfillment import gateway from oscar_mws.fulfillment.creator import FulfillmentOrderCreator try: order_creator = FulfillmentOrderCreator() except MwsFulfillmentError: logger.error( "could not create fulfillment order(s) from order {}".format( order.number), exc_info=1, extra={ 'order_number': order.number, 'user': user.id }) submitted_orders = order_creator.create_fulfillment_order(order) gateway.submit_fulfillment_orders(submitted_orders) failed_orders = [ fo.fulfillment_id for fo in submitted_orders if fo.status == fo.SUBMISSION_FAILED ] if len(failed_orders) > 0: for order_id in failed_orders: logger.error( _("Error submitting orders {} to Amazon").format( ', '.join(failed_orders))) else: logger.info( _("Successfully submitted {0} orders to Amazon").format(', '.join( [fo.fulfillment_id for fo in submitted_orders])))
def submit_order_to_mws(order, user, **kwargs): if kwargs.get('raw', False): return # these modules have to be imported here because they rely on loading # models from oscar_mws using get_model which are not fully loaded at this # point because the receivers module is imported into models.py from oscar_mws.fulfillment import gateway from oscar_mws.fulfillment.creator import FulfillmentOrderCreator order_creator = FulfillmentOrderCreator() submitted_orders = order_creator.create_fulfillment_order(order) gateway.submit_fulfillment_orders(submitted_orders) if not order_creator.errors: logger.info( _("Successfully submitted {0} orders to Amazon").format( len(submitted_orders))) else: for order_id, error in order_creator.errors.iteritems(): logger.error( _("Error submitting order {0} to Amazon: {1}").format( order_id, error))