Skip to content

This project is a comprehensive Robotic Process Automation (RPA) suite designed to eliminate inefficient, error-prone manual tasks within a legacy ERP system.

Notifications You must be signed in to change notification settings

LuisBarrichello/python-erp-automation-suite

Repository files navigation

ERP Process Automation Dashboard

Disclaimer: This project is a portfolio piece based on a real-world automation scenario. All proprietary company data, internal process details, system names, and UI assets have been removed or anonymized to protect confidentiality. The code is presented for demonstrational purposes of technical skills and is not intended to be run "out-of-the-box".

A Note on UI Image Assets

To maintain company confidentiality, all .png image files captured from the proprietary ERP interface have been intentionally removed from this public repository.

The code still contains the logic and variable paths (*_PATH) used to interact with these images. This demonstrates the image recognition technique (find_and_click function) which is central to the automation's resilience, without exposing the proprietary user interface.

🚀 Project Summary

This project is a comprehensive Robotic Process Automation (RPA) suite designed to eliminate inefficient, error-prone manual tasks within a legacy ERP system. The core of the project is a modern GUI dashboard that serves as a centralized control panel, allowing non-technical users to launch, monitor, and manage complex automation workflows safely and efficiently.

The suite automates the batch printing of Production Orders and their corresponding Attachments, reading data from Excel files and performing all necessary UI interactions, including handling dynamic pop-ups and complex, multi-step sequences.

✨ Key Features

  • Centralized GUI Dashboard: Built with CustomTkinter, providing a modern, user-friendly single point of control.
  • Concurrent Process Execution: The dashboard uses the multiprocessing module to run automations as independent, non-blocking processes, ensuring the UI remains responsive at all times.
  • Optimized Image-Based Automation: Core logic relies on PyAutoGUI's image recognition, optimized with a search_region parameter to dramatically increase search speed by limiting searches to the application window.
  • Intelligent User Error Prevention: Proactively checks if Caps Lock is active before password entry using the ctypes library, preventing a common cause of login failures.
  • Robust Login & Session Management: Features a secure login sequence that actively verifies success by detecting a specific post-login window, preventing the automation from proceeding with invalid credentials and avoiding account lockouts.
  • Advanced Sequence Handling: Implements custom logic to handle complex, interleaved UI events, such as the repeating Print -> REPORT_VIEWER dialog sequence.
  • Secure & Externalized Configuration: Manages credentials safely via .env files and application settings via a config.ini file.
  • Designed for Distribution: Code paths are handled by a custom resource_path function, ensuring that all assets are correctly located when the project is bundled into a standalone executable with PyInstaller.
  • Graceful Process Termination: The dashboard safely tracks and terminates child processes, attempting a graceful shutdown before forcing a kill.

🏛️ Architectural Overview & Flowchart

The project is designed with a clear separation of concerns, consisting of a presentation layer and an automation/logic layer.

  1. Presentation Layer (dashboard_automation.py): The user-facing GUI. Its sole responsibility is to provide a simple interface to trigger actions and display status. It knows what to run, but not how the automation works internally.
  2. Automation Layer (app_*.py scripts): Each script is a self-contained, specialized "robot" responsible for a single business process. It reads its own configuration and data, interacts with the ERP, and handles its own complex logic.

This decoupled architecture ensures that new automations can be added with minimal changes to the main dashboard.

Flowchart

flowchart_dashboard flowchart_impressao_op flowchart_anexo

📂 Project structure

The repository is organized to maintain a clear separation between the interface, the automation logic and the data resources.

automacoes/
├── assets/                 # Icons, flowcharts and images for the README
├── impressao_anexo_sanduiche/
│   ├── app_impressao_anexo_sanduiche.py  # Lógica da automação de anexos
│   └── *.png               # UI images for this automation
│   └── *.xlsx              # Data sheet for this automation
├── impressao_op/
│   ├── app_impressao_op.py # OP automation logic
│   └── *.png               # UI images for this automation
│   └── *.xlsx              # Data sheet for this automation
├── .venv/                  # Python virtual environment
├── dashboard_automation.py # GUI main script
├── utils.py                # Shared utility functions (login, find_and_click, etc.)
├── config.ini              # Configuration file (paths, timeouts)
├── .env.example            # Template for the credentials file
├── .env                    # Credentials file (ignored by Git)
├── requirements.txt        # List of project dependencies
├── PainelAutomacoes.spec   # PyInstaller configuration file for the build
└── README.md               # This file

🧠 In-Depth: Automation Challenges & Solutions

A key part of this project was overcoming the challenges of automating a legacy system.

  • Challenge 1: Interleaved Dialogs (app_impressao_op.py)

    • Problem: Printing an order with multiple Production Orders (OPs) did not generate a simple series of print dialogs. Instead, it triggered an unpredictable, repeating sequence of Print Dialog -> REPORT_VIEWER Confirmation -> Print Dialog -> ....
    • Solution: A specialized function, handle_print_and_gxr_sequence, was developed. This function runs a master loop that continuously polls for either of the two dialogs. It only exits once a full loop completes without finding any actionable window, making it robust for any number of OPs.
  • Challenge 2: Brittle UI Navigation (app_impressao_anexo_sanduiche.py)

    • Problem: The initial version of the script relied heavily on "blind" navigation (e.g., pyautogui.press('tab', presses=5)). This was extremely fragile and would break with any minor UI change.
    • Solution: The script was refactore-d to replace nearly all blind navigation with image-based find_and_click calls. This involved creating a library of reference images for UI elements (input fields, checkboxes, buttons), making the script's interactions far more reliable.

📦 Build e Deploy (Standalone .EXE)

A crucial part of the project was packaging it as a standalone, easily distributable executable (.exe) for non-technical users, utilizing PyInstaller.

  - Packaging Challenge: When creating an executable, relative paths to data files (like .png images, .xlsx spreadsheets, and config.ini) break because the script runs from a temporary directory unpacked at runtime.

  - Solution (utils.resource_path): A utility function, resource_path, was created to detect whether the script is running in development mode or as a "frozen" executable bundled by PyInstaller (by checking for sys._MEIPASS). It dynamically adjusts paths so that data files are always found, regardless of the execution context.

  - .spec File: The PainelAutomacoes.spec file was customized to ensure that all data folders (impressao_op, impressao_anexo_sanduiche) and root files (config.ini, .env) are correctly included in the final package.

To generate the executable, run the following command:

pyinstaller PainelAutomacoes.spec

🛠️ Technologies & Concepts Applied

This project showcases skills across several domains of software development and automation.

  • GUI Development:

    • CustomTkinter: For building the modern and responsive user interface.
  • Robotic Process Automation (RPA):

    • PyAutoGUI: The core engine for screen interaction, including optimized image recognition.
    • PyGetWindow: Used for reliable window identification, activation, and management.
  • Data Handling & I/O:

    • Pandas: For efficiently reading and processing data from .xlsx spreadsheets.
    • configparser: For managing external configurations from a .ini file.
  • System & Process Management:

    • multiprocessing: To launch and manage the lifecycle of automation scripts as independent, concurrent processes.
    • os & sys: For building platform-agnostic, executable-aware file paths.
    • psutil: For advanced process management, enabling the safe and targeted termination of processes by PID.
    • ctypes: For low-level interaction with the Windows API to detect the state of keyboard keys like Caps Lock.
  • Security:

    • python-dotenv: To load sensitive credentials from a local .env file.
  • Software Engineering Principles:

    • Modular Design: Separating the UI (dashboard), reusable tools (utils), and specific business logic (app_*.py).
    • DRY (Don't Repeat Yourself): Centralizing common functions in utils.py.
    • Robust Error Handling: Extensive use of try...except...finally blocks to manage failures gracefully.
    • Deployment Readiness: Designing the application to be bundled into a standalone executable using PyInstaller.

📈 Results and Impact

The implementation of this tool resulted in:

  • A drastic reduction in the time required to print batches of documents.
  • 100% elimination of manual typing errors during the process.
  • Increased team productivity, allowing staff to focus on higher-value tasks.

About

This project is a comprehensive Robotic Process Automation (RPA) suite designed to eliminate inefficient, error-prone manual tasks within a legacy ERP system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages