mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
[PUI] Build allocation sub tables (#8380)
* Add helpers methods for table row expansion * Render a simplified "line item sub table" - Akin to CUI implementation - But like, better... * Edit / delete individual stock allocations * Improvements for BuildLineTable and BuildOutputTable * Improvements for table fields * Refactoring * Refactor BuildLineTable - Calculate and cache filtered allocation values * Code cleanup * Further fixes and features * Revert new serializer field - Turns out not to be needed * Add playwright tests * Bug fix for CUI tables - Ensure allocations are correctly filtered by output ID * Adjust CUI table
This commit is contained in:
@ -7,6 +7,7 @@ from django.db import models, transaction
|
||||
from django.db.models import (
|
||||
BooleanField,
|
||||
Case,
|
||||
Count,
|
||||
ExpressionWrapper,
|
||||
F,
|
||||
FloatField,
|
||||
@ -1362,6 +1363,8 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
|
||||
part_detail = part_serializers.PartBriefSerializer(source='bom_item.sub_part', many=False, read_only=True, pricing=False)
|
||||
|
||||
# Annotated (calculated) fields
|
||||
|
||||
# Total quantity of allocated stock
|
||||
allocated = serializers.FloatField(
|
||||
label=_('Allocated Stock'),
|
||||
read_only=True
|
||||
@ -1476,7 +1479,7 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
|
||||
allocated=Coalesce(
|
||||
Sum('allocations__quantity'), 0,
|
||||
output_field=models.DecimalField()
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
ref = 'bom_item__sub_part__'
|
||||
|
@ -2505,6 +2505,7 @@ function renderBuildLineAllocationTable(element, build_line, options={}) {
|
||||
url: '{% url "api-build-item-list" %}',
|
||||
queryParams: {
|
||||
build_line: build_line.pk,
|
||||
output: options.output ?? undefined,
|
||||
},
|
||||
showHeader: false,
|
||||
columns: [
|
||||
@ -2609,9 +2610,10 @@ function renderBuildLineAllocationTable(element, build_line, options={}) {
|
||||
*/
|
||||
function loadBuildLineTable(table, build_id, options={}) {
|
||||
|
||||
const params = options.params || {};
|
||||
const output = options.output;
|
||||
|
||||
let name = 'build-lines';
|
||||
let params = options.params || {};
|
||||
let output = options.output;
|
||||
|
||||
params.build = build_id;
|
||||
|
||||
@ -2647,6 +2649,7 @@ function loadBuildLineTable(table, build_id, options={}) {
|
||||
detailFormatter: function(_index, row, element) {
|
||||
renderBuildLineAllocationTable(element, row, {
|
||||
parent_table: table,
|
||||
output: output,
|
||||
});
|
||||
},
|
||||
formatNoMatches: function() {
|
||||
@ -2730,6 +2733,15 @@ function loadBuildLineTable(table, build_id, options={}) {
|
||||
return yesNoLabel(row.bom_item_detail.inherited);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'trackable',
|
||||
title: '{% trans "Trackable" %}',
|
||||
sortable: true,
|
||||
switchable: true,
|
||||
formatter: function(value, row) {
|
||||
return yesNoLabel(row.part_detail.trackable);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'unit_quantity',
|
||||
sortable: true,
|
||||
|
Reference in New Issue
Block a user