Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order parts wizard #2770

Merged
merged 22 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b4f8136
Don't add "remove row" button if there is only one row
SchrodingersGat Mar 21, 2022
64bbcd2
Add validation checks for the PurchaseOrderLineItem serializer
SchrodingersGat Mar 21, 2022
f2806b2
Tweaks for existing form code
SchrodingersGat Mar 21, 2022
4fc605e
Render a form for ordering parts
SchrodingersGat Mar 23, 2022
293294c
Merge remote-tracking branch 'inventree/master' into order-parts-wizard
SchrodingersGat Mar 24, 2022
ed69f06
Merge remote-tracking branch 'inventree/master' into order-parts-wizard
SchrodingersGat Apr 7, 2022
e1fbd96
Refactor form renderer functions
SchrodingersGat Apr 7, 2022
e225d3b
Fix action buttons in "part" table on category page
SchrodingersGat Apr 7, 2022
b8ca7fb
Merge remote-tracking branch 'inventree/master' into order-parts-wizard
SchrodingersGat Apr 26, 2022
c66cd1d
Adds button to expand row for "extra" information
SchrodingersGat Apr 26, 2022
bf11e83
Add (empty) callbacks to prefix buttons
SchrodingersGat Apr 26, 2022
340d4d8
Launch new forms
SchrodingersGat Apr 26, 2022
24af2bd
Update console output for forms.js
SchrodingersGat Apr 27, 2022
090445f
Merge remote-tracking branch 'inventree/master' into order-parts-wizard
SchrodingersGat Apr 27, 2022
e87a026
Merge remote-tracking branch 'inventree/master' into order-parts-wizard
SchrodingersGat May 2, 2022
40c9885
Merge remote-tracking branch 'inventree/master' into order-parts-wizard
SchrodingersGat May 3, 2022
4732efb
Fix callbacks for adding new supplier part and/or purchase order "inl…
SchrodingersGat May 3, 2022
d69b581
Improved javascript log / warn / error messages
SchrodingersGat May 3, 2022
1794f65
Button to submit each row individually
SchrodingersGat May 3, 2022
8cd8581
fixes
SchrodingersGat May 3, 2022
141b764
Modal fixes
SchrodingersGat May 3, 2022
bac5a16
JS linting fxies
SchrodingersGat May 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion InvenTree/company/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def get_serializer(self, *args, **kwargs):
try:
params = self.request.query_params
kwargs['part_detail'] = str2bool(params.get('part_detail', None))
kwargs['supplier_detail'] = str2bool(params.get('supplier_detail', None))
kwargs['supplier_detail'] = str2bool(params.get('supplier_detail', True))
kwargs['manufacturer_detail'] = str2bool(params.get('manufacturer_detail', None))
kwargs['pretty'] = str2bool(params.get('pretty', None))
except AttributeError:
Expand Down
46 changes: 44 additions & 2 deletions InvenTree/order/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,30 @@ def __init__(self, *args, **kwargs):
if order_detail is not True:
self.fields.pop('order_detail')

quantity = serializers.FloatField(default=1)
received = serializers.FloatField(default=0)
quantity = serializers.FloatField(min_value=0, required=True)

def validate_quantity(self, quantity):

if quantity <= 0:
raise ValidationError(_("Quantity must be greater than zero"))

return quantity

def validate_purchase_order(self, purchase_order):

if purchase_order.status not in PurchaseOrderStatus.OPEN:
raise ValidationError(_('Order is not open'))

return purchase_order

received = serializers.FloatField(default=0, read_only=True)

overdue = serializers.BooleanField(required=False, read_only=True)

total_price = serializers.FloatField(read_only=True)

part_detail = PartBriefSerializer(source='get_base_part', many=False, read_only=True)

supplier_part_detail = SupplierPartSerializer(source='part', many=False, read_only=True)

purchase_price = InvenTreeMoneySerializer(
Expand All @@ -248,6 +264,32 @@ def __init__(self, *args, **kwargs):

order_detail = PurchaseOrderSerializer(source='order', read_only=True, many=False)

def validate(self, data):

data = super().validate(data)

supplier_part = data.get('part', None)
purchase_order = data.get('order', None)

if not supplier_part:
raise ValidationError({
'part': _('Supplier part must be specified'),
})

if not purchase_order:
raise ValidationError({
'order': _('Purchase order must be specified'),
})

# Check that the supplier part and purchase order match
if supplier_part is not None and supplier_part.supplier != purchase_order.supplier:
raise ValidationError({
'part': _('Supplier must match purchase order'),
'order': _('Purchase order must match supplier'),
})

return data

class Meta:
model = order.models.PurchaseOrderLineItem

Expand Down
13 changes: 9 additions & 4 deletions InvenTree/part/templates/part/category.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,18 @@ <h4>{% trans "Parts" %}</h4>
</button>
<ul class='dropdown-menu'>
{% if roles.part.change %}
<li><a class='dropdown-item' href='#' id='multi-part-category' title='{% trans "Set category" %}'>{% trans "Set Category" %}</a></li>
<li><a class='dropdown-item' href='#' id='multi-part-category' title='{% trans "Set category" %}'>
<span class='fas fa-sitemap'></span> {% trans "Set Category" %}
</a></li>
{% endif %}
<li><a class='dropdown-item' href='#' id='multi-part-order' title='{% trans "Order parts" %}'>{% trans "Order Parts" %}</a></li>
<li><a class='dropdown-item' href='#' id='multi-part-order' title='{% trans "Order parts" %}'>
<span class='fas fa-shopping-cart'></span> {% trans "Order Parts" %}
</a></li>
{% if report_enabled %}
<li><a class='dropdown-item' href='#' id='multi-part-print-label' title='{% trans "Print Labels" %}'>{% trans "Print Labels" %}</a></li>
<li><a class='dropdown-item' href='#' id='multi-part-print-label' title='{% trans "Print Labels" %}'>
<span class='fas fa-tag'></span> {% trans "Print Labels" %}
</a></li>
{% endif %}
<li><a class='dropdown-item' href='#' id='multi-part-export' title='{% trans "Export" %}'>{% trans "Export Data" %}</a></li>
</ul>
</div>
{% include "filter_list.html" with id="parts" %}
Expand Down
16 changes: 16 additions & 0 deletions InvenTree/part/templates/part/part_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,22 @@ <h5>
{% endif %}

$("#part-order").click(function() {

inventreeGet(
'{% url "api-part-detail" part.pk %}',
{},
{
success: function(part) {
orderParts(
[part],
{}
);
}
}
);

return;

launchModalForm("{% url 'order-parts' %}", {
data: {
part: {{ part.id }},
Expand Down
2 changes: 1 addition & 1 deletion InvenTree/templates/js/translated/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function inventreeFormDataUpload(url, data, options={}) {
}
},
error: function(xhr, status, error) {
console.log('Form data upload failure: ' + status);
console.error('Form data upload failure: ' + status);

if (options.error) {
options.error(xhr, status, error);
Expand Down
1 change: 0 additions & 1 deletion InvenTree/templates/js/translated/barcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ function onCameraAvailable(hasCamera, options) {

function onBarcodeScanCompleted(result, options) {
if (result.data == '') return;
console.log('decoded qr code:', result.data);
stopQrScanner();
postBarcodeData(result.data, options);
}
Expand Down
6 changes: 3 additions & 3 deletions InvenTree/templates/js/translated/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function constructBomUploadTable(data, options={}) {

var modal = createNewModal({
title: '{% trans "Row Data" %}',
cancelText: '{% trans "Close" %}',
closeText: '{% trans "Close" %}',
hideSubmitButton: true
});

Expand Down Expand Up @@ -617,7 +617,7 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) {
},
},
preFormContent: html,
cancelText: '{% trans "Close" %}',
closeText: '{% trans "Close" %}',
submitText: '{% trans "Add Substitute" %}',
title: '{% trans "Edit BOM Item Substitutes" %}',
afterRender: function(fields, opts) {
Expand Down Expand Up @@ -1061,7 +1061,7 @@ function loadBomTable(table, options={}) {
table.bootstrapTable('append', response);
},
error: function(xhr) {
console.log('Error requesting BOM for part=' + part_pk);
console.error('Error requesting BOM for part=' + part_pk);
showApiError(xhr);
}
}
Expand Down
8 changes: 4 additions & 4 deletions InvenTree/templates/js/translated/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ function supplierPartFields() {

return {
part: {},
supplier: {},
SKU: {
icon: 'fa-hashtag',
},
manufacturer_part: {
filters: {
part_detail: true,
manufacturer_detail: true,
},
auto_fill: true,
},
supplier: {},
SKU: {
icon: 'fa-hashtag',
},
description: {},
link: {
icon: 'fa-link',
Expand Down
4 changes: 2 additions & 2 deletions InvenTree/templates/js/translated/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function loadTableFilters(tableKey) {
if (f.length == 2) {
filters[f[0]] = f[1];
} else {
console.log(`Improperly formatted filter: ${item}`);
console.warn(`Improperly formatted filter: ${item}`);
}
}
});
Expand Down Expand Up @@ -274,7 +274,7 @@ function setupFilterList(tableKey, table, target, options={}) {
var element = $(target);

if (!element || !element.exists()) {
console.log(`WARNING: setupFilterList could not find target '${target}'`);
console.warn(`setupFilterList could not find target '${target}'`);
return;
}

Expand Down
Loading