mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-12 17:51:20 +00:00
committed by
Ankush Menat
parent
1a2a03ed98
commit
c8ca92e406
@@ -104,7 +104,13 @@ class BOM(WebsiteGenerator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
existing_boms = frappe.get_all("BOM", filters={"item": self.item}, pluck="name")
|
# ignore amended documents while calculating current index
|
||||||
|
existing_boms = frappe.get_all(
|
||||||
|
"BOM",
|
||||||
|
filters={"item": self.item, "amended_from": ["is", "not set"]},
|
||||||
|
pluck="name"
|
||||||
|
)
|
||||||
|
|
||||||
if existing_boms:
|
if existing_boms:
|
||||||
index = self.get_next_version_index(existing_boms)
|
index = self.get_next_version_index(existing_boms)
|
||||||
else:
|
else:
|
||||||
@@ -144,15 +150,12 @@ class BOM(WebsiteGenerator):
|
|||||||
pattern = "|".join(map(re.escape, delimiters))
|
pattern = "|".join(map(re.escape, delimiters))
|
||||||
bom_parts = [re.split(pattern, bom_name) for bom_name in existing_boms]
|
bom_parts = [re.split(pattern, bom_name) for bom_name in existing_boms]
|
||||||
|
|
||||||
# filter out BOMs that do not follow the following formats:
|
# filter out BOMs that do not follow the following formats: BOM/ITEM/001, BOM-ITEM-001
|
||||||
# - BOM/ITEM/001
|
|
||||||
# - BOM/ITEM/001-1
|
|
||||||
# - BOM-ITEM-001
|
|
||||||
# - BOM-ITEM-001-1
|
|
||||||
valid_bom_parts = list(filter(lambda x: len(x) > 1 and x[-1], bom_parts))
|
valid_bom_parts = list(filter(lambda x: len(x) > 1 and x[-1], bom_parts))
|
||||||
|
|
||||||
# extract the current index from the BOM parts
|
# extract the current index from the BOM parts
|
||||||
if valid_bom_parts:
|
if valid_bom_parts:
|
||||||
|
# handle cancelled and submitted documents
|
||||||
indexes = [cint(part[-1]) for part in valid_bom_parts]
|
indexes = [cint(part[-1]) for part in valid_bom_parts]
|
||||||
index = max(indexes) + 1
|
index = max(indexes) + 1
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -402,12 +402,9 @@ class TestBOM(ERPNextTestCase):
|
|||||||
(1, []),
|
(1, []),
|
||||||
(1, ["BOM#XYZ"]),
|
(1, ["BOM#XYZ"]),
|
||||||
(2, ["BOM/ITEM/001"]),
|
(2, ["BOM/ITEM/001"]),
|
||||||
(2, ["BOM/ITEM/001", "BOM/ITEM/001-1"]),
|
(2, ["BOM-ITEM-001"]),
|
||||||
(2, ["BOM-ITEM-001",]),
|
(3, ["BOM-ITEM-001", "BOM-ITEM-002"]),
|
||||||
(2, ["BOM-ITEM-001", "BOM-ITEM-001-1"]),
|
|
||||||
(3, ["BOM-ITEM-001", "BOM-ITEM-002", "BOM-ITEM-001-1"]),
|
|
||||||
(4, ["BOM-ITEM-001", "BOM-ITEM-002", "BOM-ITEM-003"]),
|
(4, ["BOM-ITEM-001", "BOM-ITEM-002", "BOM-ITEM-003"]),
|
||||||
(2, ["BOM-ITEM-001", "BOM-ITEM-001-1", "BOM-ITEM-001-2"]),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for expected_index, existing_boms in version_index_test_cases:
|
for expected_index, existing_boms in version_index_test_cases:
|
||||||
|
|||||||
Reference in New Issue
Block a user