Skip to content

Conversation

@anjusha12
Copy link
Contributor

@anjusha12 anjusha12 commented Mar 22, 2025

Feature description

This feature enhances the cost center search function by applying user-based filtering. It ensures that users only see cost centers they are permitted to access based on their assigned Bureau or Department.

Analysis and design (optional)

  • The feature follows the user permission structure in Frappe to restrict cost center selection:
  • If a user has permissions for a Bureau, fetches cost centers linked to the Bureau.
  • If no Bureau permissions exist, fetches cost centers linked to the user's permitted Departments.
  • A SQL query dynamically filters cost centers based on user permissions, ensuring only relevant records are shown.

Solution description

  • Implemented a Frappe whitelist function get_cost_center_list to filter cost centers dynamically.
  • Retrieves user permissions for Bureau or Department from User Permission.
  • Uses Bureau DocType to fetch cost centers for Bureau users.
  • Uses Department Cost Center to fetch cost centers for Department users.
  • Constructs SQL query conditions to filter cost centers dynamically.
  • Ensures that cost centers marked as disabled are excluded.
  • Supports text-based search with partial matching (LIKE operator).

Output screenshots (optional)

image
image
image
image

Areas affected and ensured

  • Cost center selection in forms where the Cost Center field is used.
  • Filtering logic in cost center searches based on user permissions.
  • Backend SQL query execution for cost center lookup.

Is there any existing behavior change of other features due to this code change?

Mention Yes or No. If Yes, provide the appropriate explanation.

Was this feature tested on the browsers?

  • Chrome
  • Mozilla Firefox
  • Opera Mini
  • Safari

@anjusha12 anjusha12 requested a review from SherinKR March 22, 2025 11:47
@hridyalakshmi hridyalakshmi changed the base branch from develop to master March 24, 2025 04:18
@anjusha12 anjusha12 requested a review from MhmdSinanKT March 24, 2025 05:47
@SherinKR SherinKR merged commit fe00fea into master Mar 24, 2025
@SherinKR SherinKR deleted the dev_anju_mar22 branch March 24, 2025 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants