mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +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:
		| @@ -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': _( | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|   | ||||
| @@ -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'); | ||||
|             } | ||||
|   | ||||
| @@ -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> | ||||
|   | ||||
| @@ -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: { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user