mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Render company image to report
This commit is contained in:
parent
9d321f4833
commit
eb6310c774
@ -425,6 +425,7 @@ class PurchaseOrderReport(ReportTemplateBase):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'description': order.description,
|
'description': order.description,
|
||||||
|
'lines': order.lines,
|
||||||
'order': order,
|
'order': order,
|
||||||
'reference': order.reference,
|
'reference': order.reference,
|
||||||
'supplier': order.supplier,
|
'supplier': order.supplier,
|
||||||
@ -459,6 +460,7 @@ class SalesOrderReport(ReportTemplateBase):
|
|||||||
return {
|
return {
|
||||||
'customer': order.customer,
|
'customer': order.customer,
|
||||||
'description': order.description,
|
'description': order.description,
|
||||||
|
'lines': order.lines,
|
||||||
'order': order,
|
'order': order,
|
||||||
'prefix': common.models.InvenTreeSetting.get_setting('SALESORDER_REFERENCE_PREFIX'),
|
'prefix': common.models.InvenTreeSetting.get_setting('SALESORDER_REFERENCE_PREFIX'),
|
||||||
'reference': order.reference,
|
'reference': order.reference,
|
||||||
|
@ -8,6 +8,7 @@ from django import template
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
|
from company.models import Company
|
||||||
from part.models import Part
|
from part.models import Part
|
||||||
from stock.models import StockItem
|
from stock.models import StockItem
|
||||||
|
|
||||||
@ -72,6 +73,39 @@ def part_image(part):
|
|||||||
return f"file://{path}"
|
return f"file://{path}"
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag()
|
||||||
|
def company_image(company):
|
||||||
|
"""
|
||||||
|
Return a fully-qualified path for a company image
|
||||||
|
"""
|
||||||
|
|
||||||
|
# If in debug mode, return the URL to the image, not a local file
|
||||||
|
debug_mode = InvenTreeSetting.get_setting('REPORT_DEBUG_MODE')
|
||||||
|
|
||||||
|
if type(company) is Company:
|
||||||
|
img = company.image.name
|
||||||
|
else:
|
||||||
|
img = ''
|
||||||
|
|
||||||
|
if debug_mode:
|
||||||
|
if img:
|
||||||
|
return os.path.join(settings.MEDIA_URL, img)
|
||||||
|
else:
|
||||||
|
return os.path.join(settings.STATIC_URL, 'img', 'blank_image.png')
|
||||||
|
|
||||||
|
else:
|
||||||
|
path = os.path.join(settings.MEDIA_ROOT, img)
|
||||||
|
path = os.path.abspath(path)
|
||||||
|
|
||||||
|
if not os.path.exists(path) or not os.path.isfile(path):
|
||||||
|
# Image does not exist
|
||||||
|
# Return the 'blank' image
|
||||||
|
path = os.path.join(settings.STATIC_ROOT, 'img', 'blank_image.png')
|
||||||
|
path = os.path.abspath(path)
|
||||||
|
|
||||||
|
return f"file://{path}"
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def internal_link(link, text):
|
def internal_link(link, text):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user