Return True in is_tax_known() when the basket is empty (#4166)
* Fix AbstractBasket's is_tax_known() to handle an empty basket
* Fix lint errors
* Added another test for is_tax_known
* Improved clarity of complex expression
Only change order line status when status is available (#3948)
* Only change order line status when status is available
It's possible for lines to have a completely different status than the order.
When a line is at an "end status" where it cannot change anymore this will result in the line being changed to something you might not want.
* line status test
* Add Python 3.10 to test suite
* Support Django 4.2, remove Python 3.7 support and add Python 3.11 support
---------
Co-authored-by: Craig Weber <crgwbr@gmail.com>
Add backward compatible order verification hash checking.
This can be enabled by specifying a `OSCAR_DEPRECATED_ORDER_VERIFY_KEY` setting, which is not set by default.
This allows projects to continue validating old order verification hashes while still changing the `SECRET_KEY`.
Do not perform stock allocation manipulations on non-stock-tracked products (#2567)
* Silently skip stock allocation manipulations if the product class doesn't track stock.
* Make it possible to cancel/consume stock allocations without line args.
You can now do:
consume_stock_allocations(order)
cancel_stock_allocations(order)
without the lines / line_quantities arguments.
Fix a race condition when using single-usage vouchers
The initial check if the voucher is available was done before creating
the order. This change adds a validation step during the order creation
within an atomic() block.
See #2101
The idea of splitting integration from unittests is good in theory
but leads to a lot of mental overhead. Besides whenever a tests
interacts with a database it isn't a unittest anyway.
Refactor the shipping_status method to return a consistent last
complete status. Since dictionaries have no guaranteed order, and also
since the shipping status queryset isn’t ordered the method didn’t
always return the actual last complete status.
Conflicts:
oscar/test/newfactories.py
tests/integration/order/model_tests.py
Backported by @maikhoepfel from #1672.
Refactor the shipping_status method to return a consistent last
complete status. Since dictionaries have no guaranteed order, and also
since the shipping status queryset isn’t ordered the method didn’t
always return the actual last complete status.
Removes the auto_now_add=True. Sets now as the default, but allows changing the date_placed field explicitly if an order is updated after it has been placed.
Fixes #1529
Replace countries.json fixture by management command
I started looking at this because on the mailing list, having the UK as
only shipping country led to confusion. This is mostly due to the
shipping address form hiding the country field if there's only one
country enabled, but all the validation then requiring UK postcodes and
phone numbers.
It's bothered me for a while that we're using a fixture to populate the
countries, which is at risk of becoming stale.
pycountry offers an excellent data source for a list of countries, so I
polished an existing management command to use it to populate the
country database.
This commit has two immediate effects:
* New setups will use a more current country database
* By default, all countries will be marked as shipping countries
pycountry also ships with localised names of the countries, which should
allow us to populate the database with localised country names.
This (possible backwards incompatible) change means subclassing and
customising shipping methods becomes much easier. Now that shipping
methods are stateless, we can instantiate at compile time and assign
them to the repository instance.
This commit also renames internal methods of the shipping repository
in as the 'prime' notion is no longer valid (as we're not injecting a
basket into each method).
It now takes the shipping charge rather than the method. This makes
sense as the shipping charge has normally been calculated before we need
the order total so there is no point in calculating it twice.
Align options for Partner.name and order's Line.partner_name field
Partner name's are allowed to be empty, but Line.partner_name wasn't.
This caused orders to fail when the partner name was indeed empty, as
reported in #1206.
So the field options for both have to be identical. Unfortunately, that
means allowing null=True for Line.partner_name. But dropping null=True
from CharFields should be done as a separate effort all over Oscar's
codebase.
Fixes #1206.
Adjust how shipping methods are handled in the repository class
The old Repository class wasn't thread safe as the method instances were
created at compile time. Since the instance is configured by setting
the basket for each request, this poses thread safety issues as two
requests could share the same method instance (one of which would have
the wrong basket assigned).
This change fiddles with how the methods are handled, ensuring that they
are instanciated within the instance methods so that thread-safety
issues go away.
Shipping methods need a gentle rewrite for v0.7 to ensure they aren't
vulnerable to such issues.
This allows different shipping methods to be handled more consistently
in multilingual sites, where same shipping method will be saved with
different names.
Fixes #850
Delete unused fields on [Shipping|Payment]EventType
is_required and sequence_number are removed. That also makes the unused
get_prerequisites function obsolete.
Those fields were added with the idea that those event flows are linear,
but all implementations assume a non-linear pattern.