mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 21:45:39 +00:00
Merge branch 'inventree:master' into matmair/issue2279
This commit is contained in:
@ -11,7 +11,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from mptt.fields import TreeNodeChoiceField
|
||||
|
||||
from InvenTree.forms import HelperForm
|
||||
from InvenTree.helpers import GetExportFormats, clean_decimal
|
||||
from InvenTree.helpers import clean_decimal
|
||||
from InvenTree.fields import RoundingDecimalFormField
|
||||
|
||||
import common.models
|
||||
@ -55,36 +55,6 @@ class PartImageDownloadForm(HelperForm):
|
||||
]
|
||||
|
||||
|
||||
class BomExportForm(forms.Form):
|
||||
""" Simple form to let user set BOM export options,
|
||||
before exporting a BOM (bill of materials) file.
|
||||
"""
|
||||
|
||||
file_format = forms.ChoiceField(label=_("File Format"), help_text=_("Select output file format"))
|
||||
|
||||
cascading = forms.BooleanField(label=_("Cascading"), required=False, initial=True, help_text=_("Download cascading / multi-level BOM"))
|
||||
|
||||
levels = forms.IntegerField(label=_("Levels"), required=True, initial=0, help_text=_("Select maximum number of BOM levels to export (0 = all levels)"))
|
||||
|
||||
parameter_data = forms.BooleanField(label=_("Include Parameter Data"), required=False, initial=False, help_text=_("Include part parameters data in exported BOM"))
|
||||
|
||||
stock_data = forms.BooleanField(label=_("Include Stock Data"), required=False, initial=False, help_text=_("Include part stock data in exported BOM"))
|
||||
|
||||
manufacturer_data = forms.BooleanField(label=_("Include Manufacturer Data"), required=False, initial=True, help_text=_("Include part manufacturer data in exported BOM"))
|
||||
|
||||
supplier_data = forms.BooleanField(label=_("Include Supplier Data"), required=False, initial=True, help_text=_("Include part supplier data in exported BOM"))
|
||||
|
||||
def get_choices(self):
|
||||
""" BOM export format choices """
|
||||
|
||||
return [(x, x.upper()) for x in GetExportFormats()]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.fields['file_format'].choices = self.get_choices()
|
||||
|
||||
|
||||
class BomDuplicateForm(HelperForm):
|
||||
"""
|
||||
Simple confirmation form for BOM duplication.
|
||||
|
@ -475,9 +475,9 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
||||
|
||||
validated = serializers.BooleanField(read_only=True, source='is_line_valid')
|
||||
|
||||
purchase_price_min = MoneyField(max_digits=10, decimal_places=6, read_only=True)
|
||||
purchase_price_min = MoneyField(max_digits=19, decimal_places=4, read_only=True)
|
||||
|
||||
purchase_price_max = MoneyField(max_digits=10, decimal_places=6, read_only=True)
|
||||
purchase_price_max = MoneyField(max_digits=19, decimal_places=4, read_only=True)
|
||||
|
||||
purchase_price_avg = serializers.SerializerMethodField()
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
<div class='alert alert-info alert-block'>
|
||||
<strong>{% trans "Requirements for BOM upload" %}:</strong>
|
||||
<ul>
|
||||
<li>{% trans "The BOM file must contain the required named columns as provided in the " %} <strong><a href="/part/bom_template/">{% trans "BOM Upload Template" %}</a></strong></li>
|
||||
<li>{% trans "The BOM file must contain the required named columns as provided in the " %} <strong><a href='#' id='bom-template-download'>{% trans "BOM Upload Template" %}</a></strong></li>
|
||||
<li>{% trans "Each part must already exist in the database" %}</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -60,4 +60,8 @@
|
||||
|
||||
enableSidebar('bom-upload');
|
||||
|
||||
{% endblock js_ready %}
|
||||
$('#bom-template-download').click(function() {
|
||||
downloadBomTemplate();
|
||||
});
|
||||
|
||||
{% endblock js_ready %}
|
@ -620,13 +620,7 @@
|
||||
});
|
||||
|
||||
$("#download-bom").click(function () {
|
||||
launchModalForm("{% url 'bom-export' part.id %}",
|
||||
{
|
||||
success: function(response) {
|
||||
location.href = response.url;
|
||||
},
|
||||
}
|
||||
);
|
||||
exportBom({{ part.id }});
|
||||
});
|
||||
|
||||
{% if report_enabled %}
|
||||
|
@ -1192,14 +1192,10 @@ class BomExport(AjaxView):
|
||||
"""
|
||||
|
||||
model = Part
|
||||
form_class = part_forms.BomExportForm
|
||||
ajax_form_title = _("Export Bill of Materials")
|
||||
|
||||
role_required = 'part.view'
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return self.renderJsonResponse(request, self.form_class())
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
||||
# Extract POSTed form data
|
||||
|
Reference in New Issue
Block a user