|
@@ -1,16 +1,13 @@
|
1
|
|
-from decimal import Decimal as D
|
2
|
|
-import warnings
|
3
|
|
-
|
4
|
1
|
from django.db import models
|
5
|
2
|
from django.conf import settings
|
6
|
|
-from oscar.core.loading import get_model
|
7
|
3
|
from django.utils.translation import ugettext_lazy as _
|
8
|
4
|
from django.utils.importlib import import_module as django_import_module
|
9
|
|
-from oscar.core.compat import AUTH_USER_MODEL
|
10
|
5
|
|
11
|
|
-from oscar.core.loading import get_class
|
|
6
|
+from oscar.core.loading import get_model, get_class
|
|
7
|
+from oscar.core.compat import AUTH_USER_MODEL
|
12
|
8
|
from oscar.models.fields import AutoSlugField
|
13
|
9
|
from oscar.apps.partner.exceptions import InvalidStockAdjustment
|
|
10
|
+
|
14
|
11
|
DefaultWrapper = get_class('partner.wrappers', 'DefaultWrapper')
|
15
|
12
|
|
16
|
13
|
|
|
@@ -255,119 +252,6 @@ class AbstractStockRecord(models.Model):
|
255
|
252
|
return False
|
256
|
253
|
return self.net_stock_level < self.low_stock_threshold
|
257
|
254
|
|
258
|
|
- # Stock wrapper methods - deprecated since 0.6
|
259
|
|
-
|
260
|
|
- @property
|
261
|
|
- def is_available_to_buy(self):
|
262
|
|
- """
|
263
|
|
- Return whether this stockrecord allows the product to be purchased
|
264
|
|
- """
|
265
|
|
- warnings.warn((
|
266
|
|
- "StockRecord.is_available_to_buy is deprecated and will be "
|
267
|
|
- "removed in 0.7. Use a strategy class to determine availability "
|
268
|
|
- "instead"), DeprecationWarning)
|
269
|
|
- return get_partner_wrapper(self.partner_id).is_available_to_buy(self)
|
270
|
|
-
|
271
|
|
- def is_purchase_permitted(self, user=None, quantity=1, product=None):
|
272
|
|
- """
|
273
|
|
- Return whether this stockrecord allows the product to be purchased by a
|
274
|
|
- specific user and quantity
|
275
|
|
- """
|
276
|
|
- warnings.warn((
|
277
|
|
- "StockRecord.is_purchase_permitted is deprecated and will be "
|
278
|
|
- "removed in 0.7. Use a strategy class to determine availability "
|
279
|
|
- "instead"), DeprecationWarning)
|
280
|
|
- return get_partner_wrapper(
|
281
|
|
- self.partner_id).is_purchase_permitted(self, user, quantity,
|
282
|
|
- product)
|
283
|
|
-
|
284
|
|
- @property
|
285
|
|
- def availability_code(self):
|
286
|
|
- """
|
287
|
|
- Return an product's availability as a code for use in CSS to add icons
|
288
|
|
- to the overall availability mark-up. For example, "instock",
|
289
|
|
- "unavailable".
|
290
|
|
- """
|
291
|
|
- warnings.warn((
|
292
|
|
- "StockRecord.availability_code is deprecated and will be "
|
293
|
|
- "removed in 0.7. Use a strategy class to determine availability "
|
294
|
|
- "instead"), DeprecationWarning)
|
295
|
|
- return get_partner_wrapper(self.partner_id).availability_code(self)
|
296
|
|
-
|
297
|
|
- @property
|
298
|
|
- def availability(self):
|
299
|
|
- """
|
300
|
|
- Return a product's availability as a string that can be displayed to
|
301
|
|
- the user. For example, "In stock", "Unavailable".
|
302
|
|
- """
|
303
|
|
- warnings.warn((
|
304
|
|
- "StockRecord.availability is deprecated and will be "
|
305
|
|
- "removed in 0.7. Use a strategy class to determine availability "
|
306
|
|
- "instead"), DeprecationWarning)
|
307
|
|
- return get_partner_wrapper(self.partner_id).availability(self)
|
308
|
|
-
|
309
|
|
- def max_purchase_quantity(self, user=None):
|
310
|
|
- """
|
311
|
|
- Return an item's availability as a string
|
312
|
|
-
|
313
|
|
- :param user: (optional) The user who wants to purchase
|
314
|
|
- """
|
315
|
|
- warnings.warn((
|
316
|
|
- "StockRecord.max_purchase_quantity is deprecated and will be "
|
317
|
|
- "removed in 0.7. Use a strategy class to determine availability "
|
318
|
|
- "instead"), DeprecationWarning)
|
319
|
|
- return get_partner_wrapper(
|
320
|
|
- self.partner_id).max_purchase_quantity(self, user)
|
321
|
|
-
|
322
|
|
- @property
|
323
|
|
- def dispatch_date(self):
|
324
|
|
- """
|
325
|
|
- Return the estimated dispatch date for a line
|
326
|
|
- """
|
327
|
|
- warnings.warn((
|
328
|
|
- "StockRecord.dispatch_date is deprecated and will be "
|
329
|
|
- "removed in 0.7. Use a strategy class to determine availability "
|
330
|
|
- "instead"), DeprecationWarning)
|
331
|
|
- return get_partner_wrapper(self.partner_id).dispatch_date(self)
|
332
|
|
-
|
333
|
|
- @property
|
334
|
|
- def lead_time(self):
|
335
|
|
- warnings.warn((
|
336
|
|
- "StockRecord.lead_time is deprecated and will be "
|
337
|
|
- "removed in 0.7. Use a strategy class to determine availability "
|
338
|
|
- "instead"), DeprecationWarning)
|
339
|
|
- return get_partner_wrapper(self.partner_id).lead_time(self)
|
340
|
|
-
|
341
|
|
- # Price methods - deprecated in 0.6
|
342
|
|
-
|
343
|
|
- @property
|
344
|
|
- def price_incl_tax(self):
|
345
|
|
- """
|
346
|
|
- Return a product's price including tax.
|
347
|
|
-
|
348
|
|
- This defaults to the price_excl_tax as tax calculations are
|
349
|
|
- domain specific. This class needs to be subclassed and tax logic
|
350
|
|
- added to this method.
|
351
|
|
- """
|
352
|
|
- warnings.warn((
|
353
|
|
- "StockRecord.price_incl_tax is deprecated and will be "
|
354
|
|
- "removed in 0.7. Use a strategy class to determine price "
|
355
|
|
- "information instead"), DeprecationWarning, stacklevel=2)
|
356
|
|
- if self.price_excl_tax is None:
|
357
|
|
- return D('0.00')
|
358
|
|
- return self.price_excl_tax + self.price_tax
|
359
|
|
-
|
360
|
|
- @property
|
361
|
|
- def price_tax(self):
|
362
|
|
- """
|
363
|
|
- Return a product's tax value
|
364
|
|
- """
|
365
|
|
- warnings.warn((
|
366
|
|
- "StockRecord.price_incl_tax is deprecated and will be "
|
367
|
|
- "removed in 0.7. Use a strategy class to determine price "
|
368
|
|
- "information instead"), DeprecationWarning)
|
369
|
|
- return get_partner_wrapper(self.partner_id).calculate_tax(self)
|
370
|
|
-
|
371
|
255
|
|
372
|
256
|
class AbstractStockAlert(models.Model):
|
373
|
257
|
"""
|