-
Notifications
You must be signed in to change notification settings - Fork 9.9k
feat(asset): make asset depreciation failure notification role configurable #50746
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?
Conversation
📝 WalkthroughWalkthroughAdds a new Accounts Settings field Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ 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)
🔇 Additional comments (2)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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
🧹 Nitpick comments (2)
erpnext/assets/doctype/asset/depreciation.py (1)
309-324: Good implementation with sensible fallback logic.The change successfully makes the depreciation failure notification role configurable while maintaining backward compatibility with "Accounts Manager" as the default fallback.
Fallback chain clarification:
The current logic is:configured_role → Accounts Manager (if not configured) → System Manager (if no recipients).However, if a custom role is configured but has no users assigned, the code skips "Accounts Manager" and goes directly to "System Manager". Consider whether this is the desired behavior, or if you want a more defensive approach:
user_role = frappe.db.get_single_value("Accounts Settings", "role_used_for_depreciation_failure") recipients = get_users_with_role(user_role or "Accounts Manager") if not recipients and user_role: # Custom role configured but has no users, try Accounts Manager recipients = get_users_with_role("Accounts Manager") if not recipients: # Last resort fallback recipients = get_users_with_role("System Manager")This ensures admins always get notified via Accounts Manager or System Manager, even if they misconfigure an empty role.
erpnext/accounts/doctype/accounts_settings/accounts_settings.json (1)
662-669: Field configuration looks good.The new field is properly configured with appropriate metadata, clear description, and logical placement in the Assets settings section.
Optional enhancement: Consider adding validation in the
AccountsSettings.validate()method to ensure the configured role exists if set. This would provide immediate feedback to administrators if they select a role that gets deleted later:def validate(self): # ... existing validation code ... self.validate_depreciation_failure_role() def validate_depreciation_failure_role(self): if self.role_used_for_depreciation_failure: if not frappe.db.exists("Role", self.role_used_for_depreciation_failure): frappe.throw(_("Role {0} does not exist").format(self.role_used_for_depreciation_failure))
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
erpnext/accounts/doctype/accounts_settings/accounts_settings.json(3 hunks)erpnext/accounts/doctype/accounts_settings/accounts_settings.py(1 hunks)erpnext/assets/doctype/asset/depreciation.py(1 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: Python Unit Tests (1)
- GitHub Check: Python Unit Tests (2)
- GitHub Check: Python Unit Tests (4)
- GitHub Check: Python Unit Tests (3)
- GitHub Check: Patch Test
- GitHub Check: Summary
🔇 Additional comments (2)
erpnext/accounts/doctype/accounts_settings/accounts_settings.py (1)
68-68: LGTM! Type hint correctly added.The type hint for the new configuration field is correctly defined and follows the same pattern as other role fields in this class.
erpnext/accounts/doctype/accounts_settings/accounts_settings.json (1)
76-76: Field ordering is appropriate.The field is logically placed after
book_asset_depreciation_entry_automatically, keeping related asset depreciation settings together.
89ace1e to
d52d986
Compare
Issue:
When asset depreciation fails, it sends a notification to the Account Manager by default.
fixes: #48878
Solution:
Added a field in Accounts Settings to configure the role
no-docs