mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Prevent recursive BOMs
- If A has B in its BOM, A cannot be added to the BOM of B
This commit is contained in:
parent
06f9c67b11
commit
f49474ace5
@ -11,7 +11,8 @@ https://docs.djangoproject.com/en/1.10/ref/settings/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
@ -28,6 +29,12 @@ DEBUG = True
|
|||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
if DEBUG:
|
||||||
|
# will output to your console
|
||||||
|
logging.basicConfig(
|
||||||
|
level = logging.DEBUG,
|
||||||
|
format = '%(asctime)s %(levelname)s %(message)s',
|
||||||
|
)
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
|
@ -353,9 +353,13 @@ class BomItem(models.Model):
|
|||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|
||||||
|
# A part cannot refer to itself in its BOM
|
||||||
if self.part == self.sub_part:
|
if self.part == self.sub_part:
|
||||||
raise ValidationError(_('A part cannot contain itself as a BOM item'))
|
raise ValidationError(_('A part cannot contain itself as a BOM item'))
|
||||||
|
|
||||||
|
for item in self.sub_part.bom_items.all():
|
||||||
|
if self.part == item.sub_part:
|
||||||
|
raise ValidationError(_("Part '{p1}' is used in BOM for '{p2}' (recursive)".format(p1=str(self.part), p2=str(self.sub_part))))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "BOM Item"
|
verbose_name = "BOM Item"
|
||||||
|
@ -60,7 +60,10 @@ $(document).ready(function(){
|
|||||||
var button = $(this);
|
var button = $(this);
|
||||||
|
|
||||||
launchDeleteForm("#modal-delete",
|
launchDeleteForm("#modal-delete",
|
||||||
button.attr('url'));
|
button.attr('url'),
|
||||||
|
{
|
||||||
|
reload: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#bom-table').on('click', '.edit-row-button', function () {
|
$('#bom-table').on('click', '.edit-row-button', function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user