-
Notifications
You must be signed in to change notification settings - Fork 9.9k
fix: include accounting dimensions in stock entries created during asset repair. #50793
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
base: develop
Are you sure you want to change the base?
fix: include accounting dimensions in stock entries created during asset repair. #50793
Conversation
|
Warning Rate limit exceeded@ljain112 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 4 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change updates erpnext/assets/doctype/asset_repair/asset_repair.py to import get_accounting_dimensions and build an accounting_dimensions dictionary that merges cost_center, project, and all dynamic accounting dimensions. Those dimensions are spread into each stock item entry created during repair and are propagated into GL entry generation. on_cancel now sets ignore_linked_doctypes to ("GL Entry", "Stock Ledger Entry"); make_gl_entries no longer mutates ignore_linked_doctypes. Additionally, erpnext/assets/doctype/asset_repair/asset_repair.js adds a show_general_ledger(frm) helper that adds an Accounting Ledger button when the document is submitted. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Files/areas to focus:
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
erpnext/assets/doctype/asset_repair/asset_repair.py (1)
279-281: Address linter warning by treatingignore_linked_doctypesas a non‑DB flagThe linter complaint about “modifying but not committing” likely comes from setting
self.ignore_linked_doctypesdirectly inmake_gl_entries. Since this is intended as a runtime flag (not a persisted field), it’s better practice to attach it toself.flags, which also avoids the “not committed” noise:- if cancel: - self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry") + if cancel: + # mark linked doctypes to ignore during cancellation; not a DB field + self.flags.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry")This should satisfy the semgrep rule while preserving existing behavior when cancelling GL/stock entries.
🧹 Nitpick comments (1)
erpnext/assets/doctype/asset_repair/asset_repair.py (1)
237-241: Accounting dimensions propagation logic looks correct; consider small refinementsThis achieves the PR goal: all accounting dimensions on
Asset Repair(includingcost_center,project, and dynamic dimensions fromget_accounting_dimensions) are now pushed into each Stock Entry item via**accounting_dimensions. That should let Stock Entry / GL logic dimension these rows correctly.Two minor points you might consider (not blockers):
Duplicate keys for standard dimensions
Ifget_accounting_dimensions()already includescost_center/project, they are specified twice in the dict; the later**{dimension: self.get(dimension) ...}just overwrites the earlier explicit values with the same values. Harmless, but you could simplify to rely on one source of truth if desired.Filtering by document type (optional)
get_accounting_dimensions()returns all enabled dimensions, regardless ofdocument_type. Some of these may not exist onAsset RepairorStock Entryitems and will just beNone. That’s generally safe, but you could tighten it by passing a filter likefilters={"disabled": 0, "document_type": self.doctype}(or to the relevant Stock Entry item doctype) if you want to avoid carrying irrelevant keys. Based onaccounting_dimension.get_accounting_dimensionssnippet, this is supported. Based on learnings, this is an optional clean‑up, not a correctness issue.Functionally, the current implementation is sound and meets the stated requirement.
Also applies to: 254-255
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
erpnext/assets/doctype/asset_repair/asset_repair.py(3 hunks)
🧰 Additional context used
🪛 GitHub Actions: Linters
erpnext/assets/doctype/asset_repair/asset_repair.py
[error] 23-33: Blocking rule fired: frappe-semgrep-rules.rules.frappe-modifying-but-not-comitting-other-method. self.make_gl_entries is called from self.on_submit; check if changes to self.ignore_linked_doctypes are committed to the database.
⏰ 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). (6)
- GitHub Check: Patch Test
- GitHub Check: Python Unit Tests (3)
- GitHub Check: Python Unit Tests (4)
- GitHub Check: Python Unit Tests (2)
- GitHub Check: Python Unit Tests (1)
- GitHub Check: Summary
🔇 Additional comments (1)
erpnext/assets/doctype/asset_repair/asset_repair.py (1)
10-12: Import ofget_accounting_dimensionsis appropriate and scoped correctlyThe new import is minimal, used only in
decrease_stock_quantity, and does not introduce any obvious circular dependency risk in this file. No changes needed here.
7acb7d7 to
147a5ee
Compare
There was a problem hiding this 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
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
erpnext/assets/doctype/asset_repair/asset_repair.js(2 hunks)
⏰ 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). (6)
- GitHub Check: Patch Test
- GitHub Check: Python Unit Tests (3)
- GitHub Check: Python Unit Tests (4)
- GitHub Check: Python Unit Tests (2)
- GitHub Check: Python Unit Tests (1)
- GitHub Check: Summary
🔇 Additional comments (1)
erpnext/assets/doctype/asset_repair/asset_repair.js (1)
76-76: LGTM! Good refactoring.Extracting the general ledger button setup into a separate method improves code organization and maintainability.
6e3997a to
cdbe8b9
Compare
Issue: Accounting dimensions are not copied in the stock entry created from the asset repair.
closes: #48854