Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chris
repanier
Commits
60117ea8
Commit
60117ea8
authored
Mar 27, 2017
by
Patrick
Browse files
Generate price list taking only "into offer" products
parent
ba46b64f
Changes
1
Hide whitespace changes
Inline
Side-by-side
repanier/xlsx/xlsx_product.py
View file @
60117ea8
...
...
@@ -14,7 +14,7 @@ from repanier.models import Product
from
repanier.tools
import
next_row
def
export
(
producer_qs
,
wb
=
None
,
producer_prices
=
True
):
def
export
_customer_prices
(
producer_qs
,
wb
=
None
,
producer_prices
=
True
):
now
=
timezone
.
now
()
if
producer_prices
:
wb
,
ws
=
new_landscape_a4_sheet
(
wb
,
"%s"
%
_
(
"Producer prices list"
),
...
...
@@ -25,10 +25,11 @@ def export(producer_qs, wb=None, producer_prices=True):
row_num
=
0
products
=
Product
.
objects
.
filter
(
is_active
=
True
,
is_into_offer
=
True
,
translations__language_code
=
translation
.
get_language
(),
producer__in
=
producer_qs
).
order_by
(
"department_for_customer
__tree_id
"
,
"department_for_customer"
,
"translations__long_name"
,
"order_average_weight"
,
).
select_related
(
...
...
@@ -42,8 +43,8 @@ def export(producer_qs, wb=None, producer_prices=True):
(
_
(
"department_for_customer"
),
15
,
product
.
department_for_customer
.
short_name
if
product
.
department_for_customer
is
not
None
else
" "
,
NumberFormat
.
FORMAT_TEXT
,
False
),
(
_
(
"is_into_offer"
),
7
,
_
(
"Yes"
)
if
product
.
is_into_offer
else
_
(
"No"
),
NumberFormat
.
FORMAT_TEXT
,
False
),
#
(_("is_into_offer"), 7, _("Yes") if product.is_into_offer else _("No"),
#
NumberFormat.FORMAT_TEXT, False),
(
_
(
"wrapped"
),
7
,
_
(
"Yes"
)
if
product
.
wrapped
else
_
(
"No"
),
NumberFormat
.
FORMAT_TEXT
,
False
),
(
_
(
"producer"
),
15
,
product
.
producer
.
short_profile_name
,
NumberFormat
.
FORMAT_TEXT
,
False
),
...
...
@@ -71,8 +72,8 @@ def export(producer_qs, wb=None, producer_prices=True):
return
wb
def
admin_export
(
request
,
queryset
,
producer_prices
=
True
):
wb
=
export
(
producer_qs
=
queryset
,
wb
=
None
,
producer_prices
=
producer_prices
)
def
admin_export
_customer_prices
(
producer_qs
,
producer_prices
=
True
):
wb
=
export
_customer_prices
(
producer_qs
=
producer_qs
,
wb
=
None
,
producer_prices
=
producer_prices
)
if
wb
is
not
None
:
response
=
HttpResponse
(
content_type
=
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
)
response
[
'Content-Disposition'
]
=
"attachment; filename={0}.xlsx"
.
format
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment