mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 05:25:42 +00:00
Merge branch 'inventree:master' into matmair/issue2279
This commit is contained in:
@ -1453,7 +1453,9 @@ class Part(MPTTModel):
|
||||
By default, will include inherited BOM items
|
||||
"""
|
||||
|
||||
return BomItem.objects.filter(self.get_bom_item_filter(include_inherited=include_inherited))
|
||||
queryset = BomItem.objects.filter(self.get_bom_item_filter(include_inherited=include_inherited))
|
||||
|
||||
return queryset.prefetch_related('sub_part')
|
||||
|
||||
def get_installed_part_options(self, include_inherited=True, include_variants=True):
|
||||
"""
|
||||
|
@ -313,6 +313,10 @@
|
||||
fields: fields,
|
||||
groups: partGroups(),
|
||||
title: '{% trans "Create Part" %}',
|
||||
reloadFormAfterSuccess: true,
|
||||
persist: true,
|
||||
persistMessage: '{% trans "Create another part after this one" %}',
|
||||
successMessage: '{% trans "Part created successfully" %}',
|
||||
onSuccess: function(data) {
|
||||
// Follow the new part
|
||||
location.href = `/part/${data.pk}/`;
|
||||
|
@ -122,7 +122,13 @@
|
||||
<h4>{% trans "Sales Order Allocations" %}</h4>
|
||||
</div>
|
||||
<div class='panel-content'>
|
||||
<table class='table table-striped table-condensed' id='sales-order-allocation-table'></table>
|
||||
|
||||
<div id='sales-order-allocation-button-toolbar'>
|
||||
<div class='btn-group' role='group'>
|
||||
{% include "filter_list.html" with id="salesorderallocation" %}
|
||||
</div>
|
||||
</div>
|
||||
<table class='table table-striped table-condensed' id='sales-order-allocation-table' data-toolbar='#sales-order-allocation-button-toolbar'></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -342,7 +348,12 @@
|
||||
<h4>{% trans "Build Order Allocations" %}</h4>
|
||||
</div>
|
||||
<div class='panel-content'>
|
||||
<table class='table table-striped table-condensed' id='build-order-allocation-table'></table>
|
||||
<div id='build-allocation-button-toolbar'>
|
||||
<div class='btn-group' role='group'>
|
||||
{% include "filter_list.html" with id="buildorderallocation" %}
|
||||
</div>
|
||||
</div>
|
||||
<table class='table table-striped table-condensed' id='build-order-allocation-table' data-toolbar='#build-allocation-button-toolbar'></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -722,6 +733,7 @@
|
||||
});
|
||||
|
||||
// Load the BOM table data in the pricing view
|
||||
{% if part.has_bom and roles.sales_order.view %}
|
||||
loadBomTable($("#bom-pricing-table"), {
|
||||
editable: false,
|
||||
bom_url: "{% url 'api-bom-list' %}",
|
||||
@ -729,6 +741,7 @@
|
||||
parent_id: {{ part.id }} ,
|
||||
sub_part_detail: true,
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
onPanelLoad("purchase-orders", function() {
|
||||
loadPartPurchaseOrderTable(
|
||||
@ -952,7 +965,7 @@
|
||||
{% if price_history %}
|
||||
var purchasepricedata = {
|
||||
labels: [
|
||||
{% for line in price_history %}'{{ line.date }}',{% endfor %}
|
||||
{% for line in price_history %}'{% render_date line.date %}',{% endfor %}
|
||||
],
|
||||
datasets: [{
|
||||
label: '{% blocktrans %}Purchase Unit Price - {{currency}}{% endblocktrans %}',
|
||||
@ -1065,7 +1078,7 @@
|
||||
{% if sale_history %}
|
||||
var salepricedata = {
|
||||
labels: [
|
||||
{% for line in sale_history %}'{{ line.date }}',{% endfor %}
|
||||
{% for line in sale_history %}'{% render_date line.date %}',{% endfor %}
|
||||
],
|
||||
datasets: [{
|
||||
label: '{% blocktrans %}Unit Price - {{currency}}{% endblocktrans %}',
|
||||
|
@ -59,13 +59,13 @@
|
||||
<ul class='dropdown-menu'>
|
||||
<li>
|
||||
<a class='dropdown-item' href='#' id='part-count'>
|
||||
<span class='fas fa-clipboard-list'></span>
|
||||
<span class='fas fa-check-circle icon-green'></span>
|
||||
{% trans "Count part stock" %}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class='dropdown-item' href='#' id='part-move'>
|
||||
<span class='fas fa-exchange-alt'></span>
|
||||
<span class='fas fa-exchange-alt icon-blue'></span>
|
||||
{% trans "Transfer part stock" %}
|
||||
</a>
|
||||
</li>
|
||||
@ -312,7 +312,7 @@
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Creation Date" %}</td>
|
||||
<td>
|
||||
{{ part.creation_date }}
|
||||
{% render_date part.creation_date %}
|
||||
{% if part.creation_user %}
|
||||
<span class='badge badge-right rounded-pill bg-dark'>{{ part.creation_user }}</span>
|
||||
{% endif %}
|
||||
|
@ -5,6 +5,7 @@ This module provides template tags for extra functionality,
|
||||
over and above the built-in Django tags.
|
||||
"""
|
||||
|
||||
from datetime import date
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -43,6 +44,52 @@ def define(value, *args, **kwargs):
|
||||
return value
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def render_date(context, date_object):
|
||||
"""
|
||||
Renders a date according to the preference of the provided user
|
||||
|
||||
Note that the user preference is stored using the formatting adopted by moment.js,
|
||||
which differs from the python formatting!
|
||||
"""
|
||||
|
||||
if date_object is None:
|
||||
return None
|
||||
|
||||
if type(date_object) == str:
|
||||
# If a string is passed, first convert it to a datetime
|
||||
date_object = date.fromisoformat(date_object)
|
||||
|
||||
# We may have already pre-cached the date format by calling this already!
|
||||
user_date_format = context.get('user_date_format', None)
|
||||
|
||||
if user_date_format is None:
|
||||
|
||||
user = context.get('user', None)
|
||||
|
||||
if user:
|
||||
# User is specified - look for their date display preference
|
||||
user_date_format = InvenTreeUserSetting.get_setting('DATE_DISPLAY_FORMAT', user=user)
|
||||
else:
|
||||
user_date_format = 'YYYY-MM-DD'
|
||||
|
||||
# Convert the format string to Pythonic equivalent
|
||||
replacements = [
|
||||
('YYYY', '%Y'),
|
||||
('MMM', '%b'),
|
||||
('MM', '%m'),
|
||||
('DD', '%d'),
|
||||
]
|
||||
|
||||
for o, n in replacements:
|
||||
user_date_format = user_date_format.replace(o, n)
|
||||
|
||||
# Update the context cache
|
||||
context['user_date_format'] = user_date_format
|
||||
|
||||
return date_object.strftime(user_date_format)
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def decimal(x, *args, **kwargs):
|
||||
""" Simplified rendering of a decimal number """
|
||||
|
Reference in New Issue
Block a user