|
@@ -1,6 +1,5 @@
|
1
|
1
|
import os
|
2
|
2
|
import six
|
3
|
|
-import warnings
|
4
|
3
|
from itertools import chain
|
5
|
4
|
from datetime import datetime, date
|
6
|
5
|
import logging
|
|
@@ -374,64 +373,6 @@ class AbstractProduct(models.Model):
|
374
|
373
|
pairs.append(value.summary())
|
375
|
374
|
return ", ".join(pairs)
|
376
|
375
|
|
377
|
|
- # Deprecated stockrecord methods
|
378
|
|
-
|
379
|
|
- @property
|
380
|
|
- def has_stockrecord(self):
|
381
|
|
- """
|
382
|
|
- Test if this product has a stock record
|
383
|
|
- """
|
384
|
|
- warnings.warn(("Product.has_stockrecord is deprecated in favour of "
|
385
|
|
- "using the stockrecord template tag. It will be "
|
386
|
|
- "removed in v0.8"), DeprecationWarning)
|
387
|
|
- return self.num_stockrecords > 0
|
388
|
|
-
|
389
|
|
- @property
|
390
|
|
- def stockrecord(self):
|
391
|
|
- """
|
392
|
|
- Return the stockrecord associated with this product. For backwards
|
393
|
|
- compatibility, this defaults to choosing the first stockrecord found.
|
394
|
|
- """
|
395
|
|
- # This is the old way of fetching a stockrecord, when they were
|
396
|
|
- # one-to-one with a product.
|
397
|
|
- warnings.warn(("Product.stockrecord is deprecated in favour of "
|
398
|
|
- "using the stockrecord template tag. It will be "
|
399
|
|
- "removed in v0.7"), DeprecationWarning)
|
400
|
|
- try:
|
401
|
|
- return self.stockrecords.all()[0]
|
402
|
|
- except IndexError:
|
403
|
|
- return None
|
404
|
|
-
|
405
|
|
- @property
|
406
|
|
- def is_available_to_buy(self):
|
407
|
|
- """
|
408
|
|
- Test whether this product is available to be purchased
|
409
|
|
- """
|
410
|
|
- warnings.warn(("Product.is_available_to_buy is deprecated in favour "
|
411
|
|
- "of using the stockrecord template tag. It will be "
|
412
|
|
- "removed in v0.7"), DeprecationWarning)
|
413
|
|
- if self.is_group:
|
414
|
|
- # If any one of this product's variants is available, then we treat
|
415
|
|
- # this product as available.
|
416
|
|
- for variant in self.variants.select_related('stockrecord').all():
|
417
|
|
- if variant.is_available_to_buy:
|
418
|
|
- return True
|
419
|
|
- return False
|
420
|
|
- if not self.get_product_class().track_stock:
|
421
|
|
- return True
|
422
|
|
- return self.has_stockrecord and self.stockrecord.is_available_to_buy
|
423
|
|
-
|
424
|
|
- def is_purchase_permitted(self, user, quantity):
|
425
|
|
- """
|
426
|
|
- Test whether this product can be bought by the passed user.
|
427
|
|
- """
|
428
|
|
- warnings.warn(("Product.is_purchase_permitted is deprecated in favour "
|
429
|
|
- "of using a partner strategy. It will be "
|
430
|
|
- "removed in v0.7"), DeprecationWarning)
|
431
|
|
- if not self.has_stockrecords:
|
432
|
|
- return False, _("No stock available")
|
433
|
|
- return self.stockrecord.is_purchase_permitted(user, quantity, self)
|
434
|
|
-
|
435
|
376
|
@property
|
436
|
377
|
def min_variant_price_incl_tax(self):
|
437
|
378
|
"""
|