2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

Refactor 'order parts' window from manufacturer part list

This commit is contained in:
Oliver Walters 2022-05-03 16:42:00 +10:00
parent bac5a16491
commit c0163a476f
2 changed files with 22 additions and 6 deletions

View File

@ -325,9 +325,17 @@
var parts = []; var parts = [];
selections.forEach(function(item) { selections.forEach(function(item) {
parts.push(item.part); var part = item.part_detail;
part.manufacturer_part = item.pk;
parts.push(part);
}); });
orderParts(
parts,
);
return;
launchModalForm("/order/purchase-order/order-parts/", { launchModalForm("/order/purchase-order/order-parts/", {
data: { data: {
parts: parts, parts: parts,

View File

@ -630,6 +630,18 @@ function orderParts(parts_list, options={}) {
afterRender: function(fields, opts) { afterRender: function(fields, opts) {
// TODO // TODO
parts.forEach(function(part) { parts.forEach(function(part) {
var filters = {
part: part.pk,
supplier_detail: true,
part_detail: true,
};
if (part.manufacturer_part) {
// Filter by manufacturer part
filters.manufacturer_part = part.manufacturer_part;
}
// Configure the "supplier part" field // Configure the "supplier part" field
initializeRelatedField({ initializeRelatedField({
name: `part_${part.pk}`, name: `part_${part.pk}`,
@ -638,11 +650,7 @@ function orderParts(parts_list, options={}) {
required: true, required: true,
type: 'related field', type: 'related field',
auto_fill: true, auto_fill: true,
filters: { filters: filters,
part: part.pk,
supplier_detail: true,
part_detail: false,
},
noResults: function(query) { noResults: function(query) {
return '{% trans "No matching supplier parts" %}'; return '{% trans "No matching supplier parts" %}';
} }