Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fixed redundant model method get_email

Tomasz Szymański5c79a41fa925
diff --git a/saleor/graphql/invoice/mutations.py b/saleor/graphql/invoice/mutations.py
index 3655c74388..75398bfd31 100644
--- a/saleor/graphql/invoice/mutations.py
+++ b/saleor/graphql/invoice/mutations.py
@@ -270,7 +270,7 @@ class SendInvoiceEmail(ModelMutation):
"Provided invoice needs to have an invoice number.",
code=InvoiceErrorCode.NUMBER_NOT_SET,
)
- if not instance.order.get_email():
+ if not instance.order.get_customer_email():
validation_errors["order"] = ValidationError(
"Provided invoice order needs an email address.",
code=InvoiceErrorCode.EMAIL_NOT_SET,
diff --git a/saleor/graphql/invoice/tests/test_invoice.py b/saleor/graphql/invoice/tests/test_invoice.py
index 1096d323a9..c71a08b9ee 100644
--- a/saleor/graphql/invoice/tests/test_invoice.py
+++ b/saleor/graphql/invoice/tests/test_invoice.py
@@ -536,7 +536,7 @@ def test_send_invoice_without_url_and_number(
@patch("saleor.invoice.emails.send_templated_mail")
-@patch("saleor.order.models.Order.get_email")
+@patch("saleor.order.models.Order.get_customer_email")
def test_send_invoice_without_email(
order_mock, email_mock, staff_api_client, permission_manage_orders, order
):
diff --git a/saleor/invoice/emails.py b/saleor/invoice/emails.py
index 3cc5c09d82..1f80919137 100644
--- a/saleor/invoice/emails.py
+++ b/saleor/invoice/emails.py
@@ -16,7 +16,7 @@ def collect_invoice_data_for_email(invoice, template):
email_context["download_url"] = invoice.url
return {
- "recipient_list": [invoice.order.get_email()],
+ "recipient_list": [invoice.order.get_customer_email()],
"template_name": template,
"context": email_context,
**send_kwargs,
@@ -31,4 +31,4 @@ def send_invoice(invoice_pk, staff_user_pk):
send_templated_mail(**email_data)
events.invoice_sent_event(user=User.objects.get(pk=staff_user_pk), invoice=invoice)
manager = get_plugins_manager()
- manager.invoice_sent(invoice, invoice.order.get_email())
+ manager.invoice_sent(invoice, invoice.order.get_customer_email())
diff --git a/saleor/order/models.py b/saleor/order/models.py
index e5f1c4c62c..7634aa5674 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -317,9 +317,6 @@ class Order(ModelWithMetadata):
def total_balance(self):
return self.total_captured - self.total.gross
- def get_email(self):
- return self.user_email or (self.user.email if self.user else None)
-
def get_total_weight(self):
return self.weight