Thursday, March 27, 2025
2 changes · 17.0
New functionality added to Odoo
Adds a new hotel and restaurant management module for handling rooms, guests, bookings, restaurant orders, and fiscal invoice printing. This helps hospitality businesses run accommodation and restaurant operations in one Odoo workflow while supporting local tax compliance needs.
Original PR description
### Summary This PR introduces a new module, `hotel_restaurant_pms`, designed for hotel and restaurant businesses. The module includes functionalities for managing hotel rooms, guests, bookings, and…
### Summary This PR introduces a new module, `hotel_restaurant_pms`, designed for hotel and restaurant businesses. The module includes functionalities for managing hotel rooms, guests, bookings, and restaurant POS orders. It also integrates with fiscalization printers to ensure compliance with local tax regulations. ### Features 1. **Hotel Room Management**: Manage rooms with attributes like type, rate, and availability. 2. **Guest Management**: Register guest information for tracking and invoicing purposes. 3. **Booking System**: Handle hotel room bookings with check-in/check-out and automated billing. 4. **Restaurant POS Integration**: Provides an interface for menu management and order processing. 5. **Fiscalization Support**: Integrates with fiscal printers to comply with tax regulations, enabling direct printing of invoices with fiscal data. 6. **Real-Time Data Synchronization**: Ensures seamless syncing between the PMS and POS components for smooth operations. ### Technical Details - **Models**: Defines core models for `hotel.room`, `hotel.guest`, `hotel.booking`, `restaurant.menu`, and `restaurant.order`. - **Views**: Provides form views for easy data entry and overview of rooms, guests, bookings, menu items, and orders. - **Fiscal Printer Service**: Adds a service to send invoice data to fiscal printers, enhancing compliance capabilities. - **Dependencies**: Built on top of the Odoo `base` and `point_of_sale` modules. ### Test Instructions 1. Install the module within the Odoo instance. 2. Set up test data in each of the models (rooms, guests, bookings, etc.). 3. Create bookings and restaurant orders to validate that invoices and stock movements are correctly generated. 4. Test fiscalization by printing an invoice with a fiscal printer (requires compatible hardware setup). ### Contribution Checklist - [x] Module code is structured following Odoo guidelines. - [x] Views and models are modular, promoting scalability and maintainability. - [x] Fiscal printer integration has been tested in a local environment. - [x] Documentation included in each model explaining field usage and constraints. ### Additional Notes This module provides a valuable integration for hotel and restaurant businesses, especially in regions where fiscal compliance is essential. Feedback on additional features or improvements is highly welcome. Thank you for reviewing this PR!
Adds a proposed eBMS fiscalization solution for a point-of-sale workflow, including transaction storage, fiscal receipt submission, and Windows packaging guidance. This matters because it outlines a path to connect sales activity with fiscal reporting and distribute the tool on Windows.
Original PR description
To create a complete solution that integrates fiscalization with a POS system, including database operations and a Windows setup file, we need to break down the tasks into manageable steps. Here’s a…
To create a complete solution that integrates fiscalization with a POS system, including database operations and a Windows setup file, we need to break down the tasks into manageable steps. Here’s a comprehensive guide to achieve this:
### Components:
1. **POS System**: A simple Python-based POS system.
2. **Database**: SQLite for simplicity.
3. **Fiscalization**: Integrating the fiscalization service.
4. **Windows Setup File**: Using `pyinstaller` to create an executable.
### Step-by-Step Guide:
#### 1. Set Up Your POS System with Database and Fiscalization
First, we'll create a Python script for the POS system that integrates SQLite and fiscalization.
#### Python Script: `pos_system.py`
```python
import sqlite3
import requests
import json
import os
# Fiscalization API endpoint and token
FISCAL_API_ENDPOINT = 'https://fiscalization-service.com/api/v1/fiscalize'
API_TOKEN = 'YOUR_API_TOKEN'
# Database setup
DB_NAME = 'pos_system.db'
def init_db():
conn = sqlite3.connect(DB_NAME)
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS transactions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
amount REAL,
currency TEXT,
date TEXT,
fiscal_receipt TEXT)''')
cursor.execute('''CREATE TABLE IF NOT EXISTS items (
id INTEGER PRIMARY KEY AUTOINCREMENT,
transaction_id INTEGER,
description TEXT,
quantity INTEGER,
price REAL,
FOREIGN KEY (transaction_id) REFERENCES transactions(id))''')
conn.commit()
conn.close()
def fiscalize_transaction(transaction):
"""
Fiscalize a transaction in Akaunting.
Args:
transaction (dict): The transaction object.
Returns:
None
"""
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {API_TOKEN}'
}
data = {
'transaction_id': transaction['id'],
'amount': transaction['amount'],
'currency': transaction['currency'],
'date': transaction['date'],
'items': [
{
'description': item['description'],
'quantity': item['quantity'],
'price': item['price']
} for item in transaction['items']
]
}
try:
response = requests.post(FISCAL_API_ENDPOINT, headers=headers, data=json.dumps(data))
if response.status_code == 200:
response_data = response.json()
transaction['fiscal_receipt'] = response_data.get('fiscal_receipt')
save_transaction(transaction)
else:
print(f'Fiscalization failed: {response.status_code} - {response.text}')
except Exception as e:
print(f'An error occurred: {e}')
def save_transaction(transaction):
"""
Save the transaction to the database.
Args:
transaction (dict): The transaction object.
Returns:
None
"""
conn = sqlite3.connect(DB_NAME)
cursor = conn.cursor()
cursor.execute('''INSERT INTO transactions (amount, currency, date, fiscal_receipt)
VALUES (?, ?, ?, ?)''', (transaction['amount'], transaction['currency'], transaction['date'], transaction['fiscal_receipt']))
transaction_id = cursor.lastrowid
for item in transaction['items']:
cursor.execute('''INSERT INTO items (transaction_id, description, quantity, price)
VALUES (?, ?, ?, ?)''', (transaction_id, item['description'], item['quantity'], item['price']))
conn.commit()
conn.close()
print(f"Transaction with ID {transaction_id} has been fiscalized and saved.")
def add_transaction():
amount = float(input("Enter amount: "))
currency = input("Enter currency: ")
date = input("Enter date (YYYY-MM-DD): ")
items = []
while True:
description = input("Enter item description (or 'done' to finish): ")
if description.lower() == 'done':
break
quantity = int(input("Enter item quantity: "))
price = float(input("Enter item price: "))
items.append({'description': description, 'quantity': quantity, 'price': price})
transaction = {
'id': None,
'amount': amount,
'currency': currency,
'date': date,
'items': items,
'fiscal_receipt': None
}
fiscalize_transaction(transaction)
def main():
init_db()
while True:
print("1. Add Transaction")
print("2. Exit")
choice = input("Enter choice: ")
if choice == '1':
add_transaction()
elif choice == '2':
break
else:
print("Invalid choice, please try again.")
if __name__ == "__main__":
main()
```
#### 2. Create a Windows Executable
To create a Windows executable from the Python script, we can use `pyinstaller`.
First, install `pyinstaller`:
```sh
pip install pyinstaller
```
Next, create the executable:
```sh
pyinstaller --onefile pos_system.py
```
This command will generate a standalone executable in the `dist` directory.
#### 3. Create a Windows Setup File
To create an installer for your application, you can use `Inno Setup`, a free installer for Windows programs.
Here is a basic script for `Inno Setup`:
#### Inno Setup Script: `setup.iss`
```ini
[Setup]
AppName=POS System
AppVersion=1.0
DefaultDirName={pf}\POS System
DefaultGroupName=POS System
OutputDir=.
OutputBaseFilename=POSSystemSetup
Compression=lzma
SolidCompression=yes
[Files]
Source: "dist\pos_system.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "pos_system.db"; DestDir: "{app}"; Flags: ignoreversion
[Icons]
Name: "{group}\POS System"; Filename: "{app}\pos_system.exe"
[Run]
Filename: "{app}\pos_system.exe"; Description: "{cm:LaunchProgram,POS System}"; Flags: nowait postinstall skipifsilent
```
### How to Use the Inno Setup Script:
1. **Download and Install Inno Setup** from [here](http://www.jrsoftware.org/isinfo.php).
2. **Open Inno Setup** and create a new script file.
3. **Copy and paste the above script** into the new script file.
4. **Adjust the paths** as needed, especially if your executable or database file is located in a different directory.
5. **Compile the script** to create the installer.
### Final Notes
- **Database Initialization:** Ensure that the `pos_system.db` file exists and is included in your setup. If it's generated dynamically, make sure your script can handle its creation on the first run.
- **Error Handling and Logging:** Enhance the error handling and logging mechanisms as needed for production use.
- **Security:** Secure your API token and any sensitive data, especially when distributing the application.
This setup will provide a basic POS system with fiscalization capabilities, using SQLite for the database, and packaged as a Windows executable with an installer. You can further customize the POS system, enhance the user interface, and add more features as required.