Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Visual changes
Tomasz Szymanski2c95af2a3ec0
diff --git a/.isort.cfg b/.isort.cfgindex 6374636deb..833333f5c4 100644--- a/.isort.cfg+++ b/.isort.cfg@@ -1,2 +1,2 @@[settings]-known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_django_optimizer,graphene_federation,graphql,graphql_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield+known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_django_optimizer,graphene_federation,graphql,graphql_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield,weasyprintdiff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex f0476b967e..420cef4187 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -6,6 +6,7 @@ from django.db import transactionfrom django.template.loader import get_templatefrom django.utils import timezonefrom prices import Money, TaxedMoney+from weasyprint import HTMLfrom ..account.models import Userfrom ..core.taxes import zero_money@@ -342,18 +343,10 @@ def match_orders_with_new_user(user: User) -> None:Order.objects.confirmed().filter(user_email=user.email, user=None).update(user=user)-def _create_pdf(rendered_template, path):- from weasyprint import HTML-- pdf_file = HTML(string=rendered_template).write_pdf(path)- return pdf_file--def generate_invoice_pdf_for_order(invoice):logo_path = static_finders.find("images/logo-light.svg")rendered_template = get_template("invoice.html").render({"invoice": invoice, "order": invoice.order, "logo_path": f"file://{logo_path}"})pdf_path = f"/tmp/{invoice.number}.pdf"- pdf_file = _create_pdf(rendered_template, pdf_path)- return pdf_file+ return HTML(string=rendered_template).write_pdf(pdf_path)diff --git a/templates/invoice.html b/templates/invoice.htmlindex b0d193d65e..6c734b6cc3 100644--- a/templates/invoice.html+++ b/templates/invoice.html@@ -63,6 +63,10 @@padding: 20px;}+ .content-tight-padded {+ padding: 0 20px 10px 20px;+ }+.normal-text {color: #28234A;}@@ -88,8 +92,8 @@padding-top: 20px;}- .row-category>td,- .row-product>td {+ .row-category > td,+ .row-product > td {border-bottom: 2px solid #EFF5F8;}@@ -152,7 +156,7 @@<br /><span class="header-category">Order:</span><br />- <span class="header-item">{{ ordr.id }}</span>+ <span class="header-item">{{ order.id }}</span><br /><span class="header-category">Date:</span>@@ -220,7 +224,7 @@<br /></div></div>- <div class="content-padded">+ <div class="content-tight-padded"><div class="content-separator"> </div></div><div class="section-left">@@ -237,11 +241,9 @@<br /><span class="normal-text">{{ order.shipping_method_name }}</span><br />- <span class="normal-text">Tracking number: 21212112</span>- <br /></div></div>- <div class="content-padded">+ <div class="content-tight-padded"><div class="content-separator"> </div></div><div class="content-padded">