Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
viggo-devries committed Apr 19, 2024
1 parent 8608eb5 commit 1b7ab6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions oscar_odin/mappings/catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def children(self) -> Tuple[Optional[List[resources.catalogue.Product]]]:
)
return (None,)

@odin.assign_field(to_field=("price", "currency", "availability", "is_available_to_buy"))
@odin.assign_field(
to_field=("price", "currency", "availability", "is_available_to_buy")
)
def map_stock_price(self) -> Tuple[Decimal, str, int]:
"""Resolve stock price using strategy and decompose into price/currency/availability."""
stock_strategy: DefaultStrategy = self.context["stock_strategy"]
Expand All @@ -229,7 +231,12 @@ def map_stock_price(self) -> Tuple[Decimal, str, int]:
price, availability, _ = stock_strategy.fetch_for_product(self.source)

if availability.is_available_to_buy:
return price.excl_tax, price.currency, getattr(availability, "num_available", 0), True
return (
price.excl_tax,
price.currency,
getattr(availability, "num_available", 0),
True,
)
else:
# There is no stock record for this product.
return Decimal(0), "", 0, False
Expand Down
2 changes: 1 addition & 1 deletion tests/reverse/test_deleting_related.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_deleting_product_related_models(self):

def test_deleting_all_related_models(self):
partner = Partner.objects.get(name="klaas")

Product.objects.create(upc="recommended_product1")

product_resource = ProductResource(
Expand Down

0 comments on commit 1b7ab6d

Please sign in to comment.