Phamos Utils
Doctypes, classes and functions to help the development process
- Author: phamos-eu
- Repository: https://github.com/phamos-eu/phamos_utils
- GitHub stars: 0
- Forks: 3
- License: MIT
- Category: Other
- Maintenance: Unmaintained
- Frappe versions: develop
Install Phamos Utils
bench get-app https://github.com/phamos-eu/phamos_utils
Add the Frappe Gems badge to your README
Maintain Phamos Utils? Paste this into your README:
[](https://frappegems.com/gems/apps/phamos-eu/phamos_utils)
About Phamos Utils
Phamos Utils
Phamos Utils is a collection of utilities for managing and updating data in the Phamos ERP system. This app includes a robust mechanism for safely updating data with automatic backup and rollback capabilities.
Safe Data Update
The SafeDataUpdate class provides a safe way to update fields in documents. It ensures that any changes made can be rolled back in case of an error. This is particularly useful for bulk updates or critical data modifications.
Features
- Backup: Before any update, the original value of the field is backed up.
- Update: The field is updated with the new value.
- Rollback: If an error occurs during the update process, all changes can be rolled back to their original state.
Usage
Example Update Function
The following example demonstrates how to use the SafeDataUpdate class to update the customer_group field of all Customer documents to "Commercial".
from phamos_utils.phamos_utils.doctype.safe_data_update.safe_data_update import SafeDataUpdate
import frappe
def your_update_function(runner, **kwargs):
"""
Example update function using safe_update.
"""
for doc in frappe.get_all("Customer", fields=["name", "customer_group"]):
runner.safe_update(doc.name, "customer_group", "Commercial")
# Create an instance of SafeDataUpdate
safe_data_update_instance = frappe.get_doc({"doctype": "Safe Data Update", "target_doctype": "Customer"})
safe_data_update_instance.insert()
# Run the test update function
safe_data_update_instance.run(your_update_function)
Graphical Interface / Rollback
After running this function, a new record of Safe Data Update will be created:

You can use the Rollback Changes button to restore the data to the original values.
Class Methods
safe_update(doc_name, field_name, new_value, update_modified=False)
- doc_name: The name of the document to update.
- field_name: The field to update.
- new_value: The new value to set.
- update_modified: Whether to update the
modifiedtimestamp of the document.
run(update_function, **kwargs)
- update_function: The function that performs the updates. This function should call
safe_updatefor each update. - kwargs: Additional arguments to pass to the update function.
rollback_changes()
Rolls back all changes made during the update process.
Logging
The SafeDataUpdate class uses Python's logging module to log information about the update process. Logs include information about successful updates, errors, and rollbacks.
Get Pull Requests from GitHub
The Get Pull Requests from GitHub doctype is a tool to fetch pull requests from a specified GitHub repository.
Usage
You can go to /app/get-pull-requests-from-github and set the following values:
- Github Base URL
- Github token
- Github Repository
- List of Parent and Child issues
After setting these values, you can press the button Get Pull Requests. This will take all URLs from List of Parent and Child issues field and search the PR in GitHub in which these URLs are mentioned. The resulting PR URLs will appear in the Resulting list of Pull Requests field:

Sort JSON
The Sort JSON doctype is a utility to sort JSON files in a consistent and predictable manner. This is particularly useful for maintaining clean and organized fixture files in your application.
Usage
- Navigate to
/app/sort-jsonin your application. - Use "Sort Fixtures" tab to run the "Export Fixtures and Sort them". This is similar to running
bench export-fixturesbut with a sort function included.

- Use the "Sort JSON" tab:

- Upload the JSON file you want to sort using the provided interface.
- Press the
Sort JSONbutton to sort the file. The sorted JSON will be displayed in the output section. - You can "Copy to Clipboard" the sorted JSON file for further use.
Features
- Consistent Sorting: Ensures that the JSON files are sorted, based on the
namekey-value. - User-Friendly Interface: Provides an easy-to-use graphical interface for sorting JSON files.
- Batch Processing: Allows sorting of multiple JSON files in one go.
Example
Before sorting:
[
{
...
"name": "Sales Invoice-field_2",
...
},
{
...
"name": "Sales Invoice-field_1",
...
}
]
After sorting:
[
{
...
"name": "Sales Invoice-field_1",
...
},
{
...
"name": "Sales Invoice-field_2",
...
}
]
Installation
Clone the repository to your
benchdirectory:git clone https://github.com/phamos-eu/phamos_utils.gitInstall the app:
bench --site your-site install-app phamos_utils
Road Map
TODOs: - [x] Include the function to sort the fixture files and make it more general and user-friendly - [ ] Add a Logging functionality for debugging and more - [ ] Move all the custom apps we created and combine them into this app. So we only have one app to rule them all! ;)
License
This project is licensed under the terms of the MIT license. See the LICENSE file for details.
Contributing
Contributions are welcome! Please submit a pull request or open an issue to discuss your changes.
Contact
For any questions or issues, please contact the Phamos GmbH support team.
Related Other apps for Frappe & ERPNext
- Erpnext — Free and Open Source Enterprise Resource Planning (ERP)
- Helpdesk — Modern, Streamlined, Free and Open Source Customer Service Software
- Print Designer — Visual print designer for Frappe / ERPNext
- Ctr — CTR模型代码和学习笔记总结
- Whitelabel — Whitelabel ERPNext
- Fossunited — fossunited.org
- Helm — Helm Chart Repository for Frappe/ERPNext
- Frappe Attachments S3 — A frappe app to upload file attachments in doctypes to s3.