Skip to content

Conversation

@NihalRoshanCK
Copy link
Contributor

@NihalRoshanCK NihalRoshanCK commented Nov 6, 2025

Now the get_warehouses_based_on_account return the the warehouse that even it is disabled
and my Stock and Account Value Comparison coming wrong

Update in version-14 and version-15

Please provide enough information so that others can review your pull request:

Explain the details for making this change. What existing problem does the pull request solve?

Screenshots/GIFs

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Nov 6, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

📝 Walkthrough

Walkthrough

The change updates get_warehouses_based_on_account in erpnext/stock/doctype/warehouse/warehouse.py by adding a filter disabled: 0 to the frappe.get_all query so disabled warehouses are excluded. No function signatures or other control flow changes were made.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single-line filter addition in warehouse.py
  • No structural, API, or multi-file changes
  • Review focus: confirm filter key/value (disabled: 0) is correct and consistent with similar queries, and check for any tests or call sites that might expect disabled warehouses to be returned

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: filtering out disabled warehouses in the get_warehouses_based_on_account function, which matches the core modification in the code.
Description check ✅ Passed The PR description describes the issue being fixed (disabled warehouses being returned) and its impact on the Stock and Account Value Comparison report, which aligns with the code changes that filter out disabled warehouses.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
erpnext/stock/doctype/warehouse/warehouse.py (1)

245-250: Consider filtering disabled warehouses in the fallback query for consistency.

The fallback query on Line 250 retrieves warehouses when using the company's default inventory account, but it doesn't filter out disabled warehouses. For consistency with the main query fix and to ensure the function consistently excludes disabled warehouses in all scenarios, consider adding the same filter here.

Apply this diff to add the disabled filter:

 		warehouses = [d.name for d in frappe.get_all("Warehouse", filters={"is_group": 0})]
+		warehouses = [d.name for d in frappe.get_all("Warehouse", filters={"is_group": 0, "disabled": 0})]
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5cc2cf5 and 9879d44.

📒 Files selected for processing (1)
  • erpnext/stock/doctype/warehouse/warehouse.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: sagarvora
Repo: frappe/erpnext PR: 49312
File: erpnext/public/js/utils/barcode_scanner.js:410-420
Timestamp: 2025-08-25T19:03:55.265Z
Learning: In ERPNext barcode scanner functionality, the set_warehouse method is intentionally designed to only use last_scanned_warehouse and not fall back to default_warehouse, as the default_warehouse is automatically handled by the backend scan API's _update_default_warehouse function which already considers all relevant warehouse defaults and business rules.
Learnt from: karm1000
Repo: frappe/erpnext PR: 48865
File: erpnext/public/js/utils/barcode_scanner.js:0-0
Timestamp: 2025-08-12T06:51:14.897Z
Learning: In ERPNext barcode scanner functionality, the `default_warehouse` returned by the scan API already handles appropriate fallback logic through the backend `_update_default_warehouse` function, which uses `get_item_warehouse_` with context (including set_warehouse and company) to consider all relevant warehouse defaults and business rules.
🪛 GitHub Actions: Linters
erpnext/stock/doctype/warehouse/warehouse.py

[error] 239-239: check-ast failed: SyntaxError: invalid syntax at line 239 (unexpected token ':')


[error] 239-239: debug-statements failed: Could not parse AST due to SyntaxError at line 239


[error] 239-239: ruff: Failed to parse due to SyntaxError at line 239 (Unexpected token ':')

🪛 GitHub Actions: Patch
erpnext/stock/doctype/warehouse/warehouse.py

[error] 239-239: SyntaxError: invalid syntax. Likely an stray extra colon after the for loop (line shows: 'for d in frappe.get_all(...) : :').

🪛 GitHub Actions: Server (Mariadb)
erpnext/stock/doctype/warehouse/warehouse.py

[error] 239-239: SyntaxError: invalid syntax at line 239 due to an extra colon after the for loop ("for d in frappe.get_all(...): :").

🪛 Ruff (0.14.3)
erpnext/stock/doctype/warehouse/warehouse.py

239-239: Expected a simple statement

(invalid-syntax)


239-240: Expected a statement

(invalid-syntax)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Summary

@mihir-kandoi mihir-kandoi self-assigned this Nov 20, 2025
Copy link
Contributor

@mihir-kandoi mihir-kandoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the linter error

@NihalRoshanCK
Copy link
Contributor Author

please fix the linter error

@mihir-kandoi but in the latest commit its indented is correct

@mihir-kandoi
Copy link
Contributor

@NihalRoshanCK did it for you. To do it yourself next time just go through this once.

@mihir-kandoi mihir-kandoi added backport version-15-hotfix and removed needs-tests This PR needs automated unit-tests. labels Nov 20, 2025
@mihir-kandoi mihir-kandoi merged commit 7172f30 into frappe:develop Nov 20, 2025
12 checks passed
mihir-kandoi added a commit that referenced this pull request Nov 20, 2025
…-50385

fix: remove disabled warehouse in get_warehouses_based_on_account (backport #50385)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants