Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make product unavailable if price is empty to avoid exception when adding product without price to basket #1913

Merged
merged 1 commit into from Feb 26, 2017

Conversation

sasha0
Copy link
Member

@sasha0 sasha0 commented Nov 22, 2015

Fixes #1912

@mvantellingen
Copy link
Contributor

Shouldn't we use the pricing policy to determine if a price is available?

@sasha0
Copy link
Member Author

sasha0 commented Nov 22, 2015

@mvantellingen right, I'll move check to pricing policy. But in general, what do you think about solution?

@@ -204,7 +204,7 @@ class StockRequired(object):
def availability_policy(self, product, stockrecord):
if not stockrecord:
return availability.Unavailable()
if not product.get_product_class().track_stock:
if not product.get_product_class().track_stock and stockrecord.price_excl_tax:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to make products which are free (price is 0) unavailable. Not sure we want, perhaps:

if not stockrecord or stockrecord.price_excl_tax is None:
    return availability.Unavailable()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Otherwise looks good?

@sasha0
Copy link
Member Author

sasha0 commented Dec 12, 2015

@mvantellingen updated PR. Please check.

@sasha0 sasha0 added this to the 1.5 milestone Feb 7, 2017
@codecov
Copy link

codecov bot commented Feb 25, 2017

Codecov Report

Merging #1913 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1913      +/-   ##
==========================================
+ Coverage   82.77%   82.77%   +<.01%     
==========================================
  Files         321      321              
  Lines       15348    15348              
==========================================
+ Hits        12704    12705       +1     
+ Misses       2644     2643       -1
Impacted Files Coverage Δ
src/oscar/apps/partner/strategy.py 82.05% <100%> (ø)
src/oscar/test/factories/partner.py 100% <ø> (+4.54%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9472625...82d9e7d. Read the comment docs.

@sasha0 sasha0 merged commit 75501db into django-oscar:master Feb 26, 2017
MrVoltz pushed a commit to EndevelCZ/django-oscar that referenced this pull request Aug 21, 2018
…ce_excl_tax

Make product unavailable if price is empty to avoid exception when adding product without price to basket
MrVoltz pushed a commit to EndevelCZ/django-oscar that referenced this pull request Aug 21, 2018
Revert changes in django-oscar#1913 and django-oscar#2294 that required a stock record to have price_excl_tax set in order to report the product as available.

Add separate checks to the basket form/add logic that checks at the time of
adding a product to the basket whether a price exists, and report an error if it doesn't.

Fixes django-oscar#2664.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants