Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't allow BOM's item code at any level of child items #27157

Merged
merged 6 commits into from
Aug 26, 2021

Conversation

ankush
Copy link
Member

@ankush ankush commented Aug 26, 2021

Steps to reproduce:

  1. Create BOM for Item A.
  2. In child item, again add Item A.
  3. Save.

Observed:
BOM gets saved.

Expected:
validation error.

Solution:
Never allow BOM's item at any level of exploded child items.

closes #26747

if same item_code is added in child items at any level, it shouldn't be allowed.
@ankush ankush added the squash Meant to tell reviewers that this PR should be squashed into a single commit while merging. label Aug 26, 2021
@ankush
Copy link
Member Author

ankush commented Aug 26, 2021

Why so many tests use same item in raw material for BOM 🤦

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 51.63% when pulling f42ffaf on ankush:bom_recursion into 73b686a on frappe:develop.

@ankush ankush changed the title fix: don't allow BOM item code at any level of BOM fix: don't allow BOM's item code at any level of child items Aug 26, 2021
@ankush ankush merged commit c07dce9 into frappe:develop Aug 26, 2021
@ankush ankush deleted the bom_recursion branch August 26, 2021 13:03
frappe-pr-bot pushed a commit to frappe-pr-bot/erpnext that referenced this pull request Aug 26, 2021
…27157)

* refactor: bom recursion checking

* fix: dont allow bom recursion

if same item_code is added in child items at any level, it shouldn't be allowed.

* test: add test for bom recursion

* test: fix broken prodplan test using recursive bom

* test: fix recursive bom in tests

(cherry picked from commit c07dce9)

# Conflicts:
#	erpnext/manufacturing/doctype/bom/test_bom.py
#	erpnext/manufacturing/doctype/production_plan/test_production_plan.py
#	erpnext/manufacturing/doctype/work_order/test_work_order.py
frappe-pr-bot pushed a commit to frappe-pr-bot/erpnext that referenced this pull request Aug 26, 2021
…27157)

* refactor: bom recursion checking

* fix: dont allow bom recursion

if same item_code is added in child items at any level, it shouldn't be allowed.

* test: add test for bom recursion

* test: fix broken prodplan test using recursive bom

* test: fix recursive bom in tests

(cherry picked from commit c07dce9)
ankush added a commit that referenced this pull request Aug 26, 2021
…#27176)

* refactor: bom recursion checking

* fix: dont allow bom recursion

if same item_code is added in child items at any level, it shouldn't be allowed.

* test: add test for bom recursion

* test: fix broken prodplan test using recursive bom

* test: fix recursive bom in tests

(cherry picked from commit c07dce9)

Co-authored-by: Ankush Menat <ankush@iwebnotes.com>
ankush added a commit that referenced this pull request Aug 26, 2021
* fix: don't allow BOM's item code at any level of child items (#27157)

* refactor: bom recursion checking

* fix: dont allow bom recursion

if same item_code is added in child items at any level, it shouldn't be allowed.

* test: add test for bom recursion

* test: fix broken prodplan test using recursive bom

* test: fix recursive bom in tests

(cherry picked from commit c07dce9)

# Conflicts:
#	erpnext/manufacturing/doctype/bom/test_bom.py
#	erpnext/manufacturing/doctype/production_plan/test_production_plan.py
#	erpnext/manufacturing/doctype/work_order/test_work_order.py

* fix: resolve conflicts

[skip ci]

* fix: conflicts

[skip ci]

* fix: resolve conflicts

Co-authored-by: Ankush Menat <ankush@iwebnotes.com>
asoral pushed a commit to asoral/erpnext that referenced this pull request Nov 12, 2021
…27157)

* refactor: bom recursion checking

* fix: dont allow bom recursion

if same item_code is added in child items at any level, it shouldn't be allowed.

* test: add test for bom recursion

* test: fix broken prodplan test using recursive bom

* test: fix recursive bom in tests
@guilmori
Copy link

guilmori commented Feb 2, 2022

Why this validation ?
My use-case: I have two Work Orders creating batch of BeerX. Then I have a third Work Order blending the 2 batches of BeerX together, creating a third batch.
Now I can't define the BOM for the blending (it has to remain the same item).

KrithiRamani pushed a commit to KrithiRamani/erpnext that referenced this pull request Mar 14, 2022
…27157) (frappe#27176)

* refactor: bom recursion checking

* fix: dont allow bom recursion

if same item_code is added in child items at any level, it shouldn't be allowed.

* test: add test for bom recursion

* test: fix broken prodplan test using recursive bom

* test: fix recursive bom in tests

(cherry picked from commit c07dce9)

Co-authored-by: Ankush Menat <ankush@iwebnotes.com>
@ankush
Copy link
Member Author

ankush commented May 30, 2022

@guilmori those scenarios were usually solvable by adding an intermediate stage of item.

Beer - unprocessed
Beer - processed

etc.

However, since this keeps popping up and increases work for those who don't want traceability at different stages, I've just removed this validation for cases where child items do not have BOM (further explosion)

ref: #31175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport version-13-hotfix old-backport version-12-hotfix squash Meant to tell reviewers that this PR should be squashed into a single commit while merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: BOM: Allowed to create recursive BOMs
3 participants