Report template updates (#4454)

* Update default purchase order report template

- Add line pricing data
- Add extra lines
- Add methods for returning total line item price
- Include total order price

* Similar updates for sales order reports
This commit is contained in:
Oliver 2023-03-05 23:59:54 +11:00 committed by GitHub
parent 5ba75c868d
commit ba4e264e6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 305 additions and 231 deletions

View File

@ -978,6 +978,13 @@ class OrderLineItem(models.Model):
validators=[MinValueValidator(0)],
)
@property
def total_line_price(self):
"""Return the total price for this line item"""
if self.price:
return self.quantity * self.price
reference = models.CharField(max_length=100, blank=True, verbose_name=_('Reference'), help_text=_('Line item reference'))
notes = models.CharField(max_length=500, blank=True, verbose_name=_('Notes'), help_text=_('Line item notes'))
@ -1094,6 +1101,11 @@ class PurchaseOrderLineItem(OrderLineItem):
help_text=_('Unit purchase price'),
)
@property
def price(self):
"""Return the 'purchase_price' field as 'price'"""
return self.purchase_price
destination = TreeForeignKey(
'stock.StockLocation', on_delete=models.SET_NULL,
verbose_name=_('Destination'),
@ -1200,6 +1212,11 @@ class SalesOrderLineItem(OrderLineItem):
help_text=_('Unit sale price'),
)
@property
def price(self):
"""Return the 'sale_price' field as 'price'"""
return self.sale_price
shipped = RoundingDecimalField(
verbose_name=_('Shipped'),
help_text=_('Shipped quantity'),

View File

@ -1,115 +1 @@
{% extends "report/inventree_report_base.html" %}
{% load i18n %}
{% load report %}
{% load barcode %}
{% load inventree_extras %}
{% block page_margin %}
margin: 2cm;
margin-top: 4cm;
{% endblock %}
{% block bottom_left %}
content: "v{{report_revision}} - {{ date.isoformat }}";
{% endblock %}
{% block bottom_center %}
content: "{% inventree_version shortstring=True %}";
{% endblock %}
{% block style %}
.header-right {
text-align: right;
float: right;
}
.logo {
height: 20mm;
vertical-align: middle;
}
.thumb-container {
width: 32px;
display: inline;
}
.part-thumb {
max-width: 32px;
max-height: 32px;
display: inline;
}
.part-text {
display: inline;
}
table {
border: 1px solid #eee;
border-radius: 3px;
border-collapse: collapse;
width: 100%;
font-size: 80%;
}
table td {
border: 1px solid #eee;
}
table td.shrink {
white-space: nowrap
}
table td.expand {
width: 99%
}
{% endblock %}
{% block header_content %}
<img class='logo' src='{% company_image supplier %}' alt="{{ supplier }}" width='150'>
<div class='header-right'>
<h3>{% trans "Purchase Order" %} {{ prefix }}{{ reference }}</h3>
{% if supplier %}{{ supplier.name }}{% else %}{% trans "Supplier was deleted" %}{% endif %}
</div>
{% endblock %}
{% block page_content %}
<h3>{% trans "Line Items" %}</h3>
<table class='table table-striped table-condensed'>
<thead>
<tr>
<th>{% trans "Part" %}</th>
<th>{% trans "Quantity" %}</th>
<th>{% trans "Reference" %}</th>
<th>{% trans "Note" %}</th>
</tr>
</thead>
<tbody>
{% for line in lines.all %}
<tr>
<td>
<div class='thumb-container'>
<img src='{% part_image line.part.part %}' class='part-thumb'>
</div>
<div class='part-text'>
{{ line.part.part.full_name }}
</div>
</td>
<td>{% decimal line.quantity %}</td>
<td>{{ line.reference }}</td>
<td>{{ line.notes }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
{% extends "report/inventree_po_report_base.html" %}

View File

@ -0,0 +1,143 @@
{% extends "report/inventree_report_base.html" %}
{% load i18n %}
{% load report %}
{% load barcode %}
{% load inventree_extras %}
{% block page_margin %}
margin: 2cm;
margin-top: 4cm;
{% endblock %}
{% block bottom_left %}
content: "v{{report_revision}} - {{ date.isoformat }}";
{% endblock %}
{% block bottom_center %}
content: "{% inventree_version shortstring=True %}";
{% endblock %}
{% block style %}
.header-right {
text-align: right;
float: right;
}
.logo {
height: 20mm;
vertical-align: middle;
}
.thumb-container {
width: 32px;
display: inline;
}
.part-thumb {
max-width: 32px;
max-height: 32px;
display: inline;
}
.part-text {
display: inline;
}
table {
border: 1px solid #eee;
border-radius: 3px;
border-collapse: collapse;
width: 100%;
font-size: 80%;
}
table td {
border: 1px solid #eee;
}
table td.shrink {
white-space: nowrap
}
table td.expand {
width: 99%
}
{% endblock %}
{% block header_content %}
<img class='logo' src='{% company_image supplier %}' alt="{{ supplier }}" width='150'>
<div class='header-right'>
<h3>{% trans "Purchase Order" %} {{ prefix }}{{ reference }}</h3>
{% if supplier %}{{ supplier.name }}{% else %}{% trans "Supplier was deleted" %}{% endif %}
</div>
{% endblock %}
{% block page_content %}
<h3>{% trans "Line Items" %}</h3>
<table class='table table-striped table-condensed'>
<thead>
<tr>
<th>{% trans "Part" %}</th>
<th>{% trans "Reference" %}</th>
<th>{% trans "Quantity" %}</th>
<th>{% trans "Unit Price" %}</th>
<th>{% trans "Total Price" %}</th>
<th>{% trans "Note" %}</th>
</tr>
</thead>
<tbody>
{% for line in lines.all %}
<tr>
<td>
<div class='thumb-container'>
<img src='{% part_image line.part.part %}' class='part-thumb'>
</div>
<div class='part-text'>
{{ line.part.part.full_name }}
</div>
</td>
<td>{{ line.reference }}</td>
<td>{% decimal line.quantity %}</td>
<td>{% include "price_data.html" with price=line.purchase_price %}</td>
<td>{% include "price_data.html" with price=line.total_line_price %}</td>
<td>{{ line.notes }}</td>
</tr>
{% endfor %}
{% if extra_lines %}
<tr><th colspan='6'>{% trans "Extra Line Items" %}</th></tr>
{% for line in extra_lines.all %}
<tr>
<td><!-- No part --></td>
<td>{{ line.reference }}</td>
<td>{% decimal line.quantity %}</td>
<td>{% include "price_data.html" with price=line.price %}</td>
<td>{% include "price_data.html" with price=line.total_line_price %}</td>
<td>{{ line.notes }}</td>
</tr>
{% endfor %}
{% endif %}
<tr>
<td></td>
<td></td>
<td></td>
<th>{% trans "Total" %}</th>
<td>{% include "price_data.html" with price=order.total_price %}</td>
<td></td>
</tr>
</tbody>
</table>
{% endblock %}

View File

@ -1,116 +1 @@
{% extends "report/inventree_report_base.html" %}
{% load i18n %}
{% load report %}
{% load barcode %}
{% load inventree_extras %}
{% load markdownify %}
{% block page_margin %}
margin: 2cm;
margin-top: 4cm;
{% endblock %}
{% block bottom_left %}
content: "v{{report_revision}} - {{ date.isoformat }}";
{% endblock %}
{% block bottom_center %}
content: "{% inventree_version shortstring=True %}";
{% endblock %}
{% block style %}
.header-right {
text-align: right;
float: right;
}
.logo {
height: 20mm;
vertical-align: middle;
}
.thumb-container {
width: 32px;
display: inline;
}
.part-thumb {
max-width: 32px;
max-height: 32px;
display: inline;
}
.part-text {
display: inline;
}
table {
border: 1px solid #eee;
border-radius: 3px;
border-collapse: collapse;
width: 100%;
font-size: 80%;
}
table td {
border: 1px solid #eee;
}
table td.shrink {
white-space: nowrap
}
table td.expand {
width: 99%
}
{% endblock %}
{% block header_content %}
<img class='logo' src='{% company_image customer %}' alt="{{ customer }}" width='150'>
<div class='header-right'>
<h3>{% trans "Sales Order" %} {{ prefix }}{{ reference }}</h3>
{{ customer.name }}
</div>
{% endblock %}
{% block page_content %}
<h3>{% trans "Line Items" %}</h3>
<table class='table table-striped table-condensed'>
<thead>
<tr>
<th>{% trans "Part" %}</th>
<th>{% trans "Quantity" %}</th>
<th>{% trans "Reference" %}</th>
<th>{% trans "Note" %}</th>
</tr>
</thead>
<tbody>
{% for line in lines.all %}
<tr>
<td>
<div class='thumb-container'>
<img src='{% part_image line.part %}' class='part-thumb'>
</div>
<div class='part-text'>
{{ line.part.full_name }}
</div>
</td>
<td>{% decimal line.quantity %}</td>
<td>{{ line.reference }}</td>
<td>{{ line.notes }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
{% extends "report/inventree_so_report_base.html" %}

View File

@ -0,0 +1,143 @@
{% extends "report/inventree_report_base.html" %}
{% load i18n %}
{% load report %}
{% load barcode %}
{% load inventree_extras %}
{% load markdownify %}
{% block page_margin %}
margin: 2cm;
margin-top: 4cm;
{% endblock %}
{% block bottom_left %}
content: "v{{report_revision}} - {{ date.isoformat }}";
{% endblock %}
{% block bottom_center %}
content: "{% inventree_version shortstring=True %}";
{% endblock %}
{% block style %}
.header-right {
text-align: right;
float: right;
}
.logo {
height: 20mm;
vertical-align: middle;
}
.thumb-container {
width: 32px;
display: inline;
}
.part-thumb {
max-width: 32px;
max-height: 32px;
display: inline;
}
.part-text {
display: inline;
}
table {
border: 1px solid #eee;
border-radius: 3px;
border-collapse: collapse;
width: 100%;
font-size: 80%;
}
table td {
border: 1px solid #eee;
}
table td.shrink {
white-space: nowrap
}
table td.expand {
width: 99%
}
{% endblock %}
{% block header_content %}
<img class='logo' src='{% company_image customer %}' alt="{{ customer }}" width='150'>
<div class='header-right'>
<h3>{% trans "Sales Order" %} {{ prefix }}{{ reference }}</h3>
{{ customer.name }}
</div>
{% endblock %}
{% block page_content %}
<h3>{% trans "Line Items" %}</h3>
<table class='table table-striped table-condensed'>
<thead>
<tr>
<th>{% trans "Part" %}</th>
<th>{% trans "Reference" %}</th>
<th>{% trans "Quantity" %}</th>
<th>{% trans "Unit Price" %}</th>
<th>{% trans "Total Price" %}</th>
<th>{% trans "Note" %}</th>
</tr>
</thead>
<tbody>
{% for line in lines.all %}
<tr>
<td>
<div class='thumb-container'>
<img src='{% part_image line.part %}' class='part-thumb'>
</div>
<div class='part-text'>
{{ line.part.full_name }}
</div>
</td>
<td>{{ line.reference }}</td>
<td>{% decimal line.quantity %}</td>
<td>{% include "price_data.html" with price=line.sale_price %}</td>
<td>{% include "price_data.html" with price=line.total_line_price %}</td>
<td>{{ line.notes }}</td>
</tr>
{% endfor %}
{% if extra_lines %}
<tr><th colspan='6'>{% trans "Extra Line Items" %}</th></tr>
{% for line in extra_lines.all %}
<tr>
<td><!-- No part --></td>
<td>{{ line.reference }}</td>
<td>{% decimal line.quantity %}</td>
<td>{% include "price_data.html" with price=line.price %}</td>
<td>{% include "price_data.html" with price=line.total_line_price %}</td>
<td>{{ line.notes }}</td>
</tr>
{% endfor %}
{% endif %}
<tr>
<td></td>
<td></td>
<td></td>
<th>{% trans "Total" %}</th>
<td>{% include "price_data.html" with price=order.total_price %}</td>
<td></td>
</tr>
</tbody>
</table>
{% endblock %}