2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 13:35:40 +00:00

Disable BOM requirement (#6719)

* Add new setting STOCK_ENFORCE_BOM_INSTALLATION

- Defaults to True (legacy)

* Add logic to bypass BOM check

* Update CUI to reflect new logic

* Render InstalledItemsTable in PUI
This commit is contained in:
Oliver
2024-03-15 17:53:58 +11:00
committed by GitHub
parent 160d014e44
commit a00d5ab4b5
9 changed files with 111 additions and 6 deletions

View File

@ -1750,6 +1750,14 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'default': False,
'validator': bool,
},
'STOCK_ENFORCE_BOM_INSTALLATION': {
'name': _('Check BOM when installing items'),
'description': _(
'Installed stock items must exist in the BOM for the parent part'
),
'default': True,
'validator': bool,
},
'BUILDORDER_REFERENCE_PATTERN': {
'name': _('Build Order Reference Pattern'),
'description': _(

View File

@ -584,9 +584,14 @@ class InstallStockItemSerializer(serializers.Serializer):
parent_item = self.context['item']
parent_part = parent_item.part
# Check if the selected part is in the Bill of Materials of the parent item
if not parent_part.check_if_part_in_bom(stock_item.part):
raise ValidationError(_('Selected part is not in the Bill of Materials'))
if common.models.InvenTreeSetting.get_setting(
'STOCK_ENFORCE_BOM_INSTALLATION', backup_value=True, cache=False
):
# Check if the selected part is in the Bill of Materials of the parent item
if not parent_part.check_if_part_in_bom(stock_item.part):
raise ValidationError(
_('Selected part is not in the Bill of Materials')
)
return stock_item

View File

@ -183,7 +183,10 @@
$('#stock-item-install').click(function() {
{% settings_value "STOCK_ENFORCE_BOM_INSTALLATION" as enforce_bom %}
installStockItem({{ item.pk }}, {{ item.part.pk }}, {
enforce_bom: {% js_bool enforce_bom %},
onSuccess: function(response) {
$("#installed-table").bootstrapTable('refresh');
}

View File

@ -22,6 +22,7 @@
{% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" icon="fa-users" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_LOCATION_DEFAULT_ICON" icon="fa-icons" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_SHOW_INSTALLED_ITEMS" icon="fa-sitemap" %}
{% include "InvenTree/settings/setting.html" with key="STOCK_ENFORCE_BOM_INSTALLATION" icon="fa-check-circle" %}
</tbody>
</table>

View File

@ -3204,7 +3204,7 @@ function installStockItem(stock_item_id, part_id, options={}) {
auto_fill: true,
filters: {
trackable: true,
in_bom_for: part_id,
in_bom_for: options.enforce_bom ? part_id : undefined,
}
},
stock_item: {