mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
afb927258c
@ -933,3 +933,19 @@ class BomItem(models.Model):
|
||||
base_quantity = self.quantity * build_quantity
|
||||
|
||||
return base_quantity + self.get_overage_quantity(base_quantity)
|
||||
|
||||
@property
|
||||
def price_range(self):
|
||||
""" Return the price-range for this BOM item. """
|
||||
|
||||
prange = self.sub_part.get_price_range(self.quantity)
|
||||
|
||||
if prange is None:
|
||||
return prange
|
||||
|
||||
pmin, pmax = prange
|
||||
|
||||
if pmin == pmax:
|
||||
return str(pmin)
|
||||
|
||||
return "{pmin} to {pmax}".format(pmin=pmin, pmax=pmax)
|
||||
|
@ -122,6 +122,7 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
||||
|
||||
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
||||
sub_part_detail = PartBriefSerializer(source='sub_part', many=False, read_only=True)
|
||||
price_range = serializers.CharField(read_only=True)
|
||||
|
||||
@staticmethod
|
||||
def setup_eager_loading(queryset):
|
||||
@ -131,6 +132,7 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
||||
queryset = queryset.prefetch_related('sub_part')
|
||||
queryset = queryset.prefetch_related('sub_part__category')
|
||||
queryset = queryset.prefetch_related('sub_part__stock_items')
|
||||
queryset = queryset.prefetch_related('sub_part__supplier_parts__pricebreaks')
|
||||
return queryset
|
||||
|
||||
class Meta:
|
||||
@ -142,6 +144,7 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
||||
'sub_part',
|
||||
'sub_part_detail',
|
||||
'quantity',
|
||||
'price_range',
|
||||
'overage',
|
||||
'note',
|
||||
]
|
||||
|
@ -149,8 +149,22 @@ function loadBomTable(table, options) {
|
||||
|
||||
return renderLink(text, row.sub_part_detail.url + "stock/");
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
cols.push(
|
||||
{
|
||||
field: 'price_range',
|
||||
title: 'Price',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
if (value) {
|
||||
return value;
|
||||
} else {
|
||||
return "<span class='warning-msg'>No pricing available</span>";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Part notes
|
||||
|
Loading…
Reference in New Issue
Block a user