Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove unused methods
Anna Siwik7a6cb7c19274
diff --git a/saleor/cart/models.py b/saleor/cart/models.pyindex bc602ebd78..4fecdc68ad 100644--- a/saleor/cart/models.py+++ b/saleor/cart/models.py@@ -147,17 +147,11 @@ class Cart(models.Model):def __len__(self):return self.lines.count()- # pylint: disable=R0201- def get_subtotal(self, item, **kwargs):- """Return the cost of a cart line."""- return item.get_total(**kwargs)-- def get_total(self, **kwargs):+ def get_total(self):"""Return the total cost of the cart prior to shipping."""- subtotals = [- self.get_subtotal(item, **kwargs) for item in self.lines.all()]+ subtotals = [line.get_total() for line in self.lines.all()]if not subtotals:- raise AttributeError('Calling get_total() on an empty item set')+ raise AttributeError('Calling get_total() on an empty cart')zero = Price(0, currency=settings.DEFAULT_CURRENCY)return sum(subtotals, zero)diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex a76ae48f25..01ce15d4a9 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -370,7 +370,7 @@ def create_payment(delivery_group):variant='default',transaction_id=str(fake.random_int(1, 100000)),currency=settings.DEFAULT_CURRENCY,- total=order.get_total().gross,+ total=order.total.gross,delivery=order.shipping_price.gross,customer_ip_address=fake.ipv4(),billing_first_name=order.billing_address.first_name,diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.pyindex 711c3fafc6..b7fca98536 100644--- a/saleor/dashboard/order/views.py+++ b/saleor/dashboard/order/views.py@@ -53,8 +53,8 @@ def order_details(request, order_pk):all_payments = order.payments.exclude(status=PaymentStatus.INPUT)payment = order.payments.last()groups = list(order)- captured = preauthorized = Price(0, currency=order.get_total().currency)- balance = captured - order.get_total()+ captured = preauthorized = Price(0, currency=order.total.currency)+ balance = captured - order.totalif payment:can_capture = (payment.status == PaymentStatus.PREAUTH and@@ -66,7 +66,7 @@ def order_details(request, order_pk):preauthorized = payment.get_total_price()if payment.status == PaymentStatus.CONFIRMED:captured = payment.get_captured_price()- balance = captured - order.get_total()+ balance = captured - order.totalelse:can_capture = can_release = can_refund = False@@ -109,7 +109,7 @@ def order_add_note(request, order_pk):def capture_payment(request, order_pk, payment_pk):order = get_object_or_404(Order, pk=order_pk)payment = get_object_or_404(order.payments, pk=payment_pk)- amount = order.get_total().quantize('0.01').gross+ amount = order.total.quantize('0.01').grossform = CapturePaymentForm(request.POST or None, payment=payment,initial={'amount': amount})if form.is_valid() and form.capture():diff --git a/saleor/order/models.py b/saleor/order/models.pyindex 4b46090fec..d379cab499 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -183,9 +183,15 @@ class Order(models.Model):self.total_net = priceself.total_tax = Price(price.tax, currency=price.currency)+ def get_total(self):+ subtotals = [group.get_total() for group in self]+ if not subtotals:+ raise AttributeError('Calling get_total() on an empty order')+ return sum(subtotals[1:], subtotals[0])+def get_subtotal_without_voucher(self):if self.get_lines():- return super().get_total()+ return self.get_total()return Price(net=0, currency=settings.DEFAULT_CURRENCY)def can_cancel(self):@@ -253,7 +259,7 @@ class DeliveryGroup(models.Model):return self.status not in {GroupStatus.CANCELLED, GroupStatus.SHIPPED}def get_total(self):- subtotals = [item.get_total() for item in self]+ subtotals = [line.get_total() for line in self]if not subtotals:raise AttributeError('Calling get_total() on an empty shipment group')diff --git a/saleor/order/views.py b/saleor/order/views.pyindex 6043a013f8..c8bd9d266c 100644--- a/saleor/order/views.py+++ b/saleor/order/views.py@@ -83,10 +83,11 @@ def start_payment(request, order, variant):if waiting_payments:return redirect('order:payment', token=order.token)billing = order.billing_address- total = order.get_total()+ total = order.totaldefaults = {'total': total.gross,- 'tax': total.tax, 'currency': total.currency,+ 'tax': total.tax,+ 'currency': total.currency,'delivery': order.shipping_price.gross,'billing_first_name': billing.first_name,'billing_last_name': billing.last_name,