Summary
Send push notifications from Odoo 19 to your mobile app with Firebase Cloud Messaging. Approval alerts, deep links, multilingual messages and full history. It supports task approval and rejection notifications, stores notification history in Odoo, and includes the relevant site activity id in the notification payload to support navigation to the corresponding activity in the Flutter application.
The integration provides a centralized notification service that handles Firebase authentication, constructs notification messages, sends them to Firebase, and records notification details in Odoo.
The implementation also allows mobile users to register or update their Firebase Cloud Messaging tokens and retrieve their notification history through API endpoints.
Firebase Configuration
The Firebase integration is configured through the Odoo Settings menu.
Navigation: Settings → General Settings → Firebase Cloud Messaging Configuration
The configuration includes the following fields:
- Firebase Project ID: The identifier of the Firebase project used to send notifications.
- Service Account JSON: The complete JSON credentials file for the Firebase service account. These credentials are used to authenticate requests to Firebase Cloud Messaging.
The configuration is available to users belonging to the System Administration group.
Once the Firebase project details and service account credentials are configured, the Odoo backend can authenticate with Firebase and send push notifications through the Firebase Cloud Messaging HTTP v1 API.
Firebase Authentication
The integration uses the Firebase Cloud Messaging HTTP v1 API with OAuth 2.0 authentication.
When a notification needs to be sent, the backend reads the configured service account credentials and generates an OAuth 2.0 access token using the Google authentication libraries.
The generated token is included in the authorization header of the request sent to Firebase.
This approach allows Odoo to authenticate its outgoing notification requests using the configured service account rather than requiring a manually maintained access token.
The integration uses the following Python dependencies:
Register or Update Firebase Token
The mobile application must register its Firebase Cloud Messaging token with Odoo so that the backend knows which device should receive notifications.
API Endpoint: POST /api/user/{user_id}/update_fcm_token
Authentication: Authenticated Odoo user session.
Request Payload:
{
"firebaseUserIdentifier": "<firebase_fcm_token>"
}
The API retrieves the specified Odoo user and updates the fcm_token field in the user's record. If the user already has a registered token, the existing token is overwritten with the new one.
If the token is missing or the specified user does not exist, the API returns an error response.
Successful Response:
{
"status": "success",
"message": "FCM token updated successfully"
}
Workflow:
- The Flutter application obtains the FCM token from the Firebase SDK.
- The application calls the token registration API.
- Odoo validates the supplied token and user record.
- The token is saved in the corresponding
res.users record.
- The stored token is used when sending notifications to that user.
The mobile application should call this API when appropriate, such as when the user opens the home screen and the current token needs to be synchronized.
Task Approval and Rejection Notifications
The integration provides reusable methods for sending task approval and rejection notifications from the Odoo backend.
The notification service exposes the following methods:
send_task_approval_notification()
send_task_rejection_notification()
These methods prepare the notification title and message, identify the notification type, and include the relevant siteActivityId for mobile application navigation.
Task Approval
When the task approval workflow invokes the notification service, the following notification is prepared:
- Title: Task Approved
- Message: Your task has been approved
- Notification Type:
task_approval
Task Rejection
When the task rejection workflow invokes the notification service, the following notification is prepared:
- Title: Task Rejected
- Message: Your task has been rejected
- Notification Type:
task_reject
The notification messages are prepared using the recipient's language preference, with English as the fallback language.
The task approval and rejection methods are reusable service functions. They can be called from the corresponding business logic in Odoo when a task is approved or rejected.
Firebase Notification Payload
The notification service constructs a message containing the recipient's FCM token, notification title, notification body, and additional data required by the mobile application.
An example task approval payload is shown below:
{
"message": {
"token": "<user_fcm_token>",
"notification": {
"title": "Task Approved",
"body": "Your task has been approved"
},
"data": {
"type": "task_approval",
"siteActivityId": "123"
}
}
}
The fields serve the following purposes:
- token: Identifies the target device or registration token.
- notification.title: Specifies the notification heading displayed to the user.
- notification.body: Contains the notification message.
- data.type: Identifies the type of notification.
- data.siteActivityId: Identifies the relevant site activity for navigation in the Flutter application.
The siteActivityId is included as a string in the data payload to support the mobile application's navigation requirements.
The service also supports additional custom data fields when sending notifications through its generic notification method.
After constructing the message, Odoo sends it to the Firebase Cloud Messaging HTTP v1 API.
Notification History in Odoo
The integration introduces a new Odoo model named mobile.notification to maintain a history of notifications sent through the service.
Each notification record stores the following information:
- Title: The notification title.
- User: The Odoo user associated with the notification.
- Description: The notification message.
- Type: The notification type, such as
task_approval or task_reject.
- Site Activity ID: The identifier associated with mobile application navigation.
- Data Payload: The JSON payload submitted to Firebase.
- Created On: The date and time the notification record was created.
When the notification service prepares a message for delivery, it creates a notification history record and stores the outgoing payload for debugging and reference.
This provides a record of the notification details and the data associated with the request.
Retrieve Notification History
The integration provides an API for retrieving notification history associated with a particular Odoo user.
API Endpoint: POST /api/notification/{user_id}
Authentication: Public route.
The API supports optional date filters to retrieve notifications within a specified period.
Request Payload:
{
"start_date": "2026-01-01",
"end_date": "2026-12-31"
}
Both date filters are optional. When provided, the API returns notifications created within the specified date range, ordered from newest to oldest.
Successful Response:
{
"status": "success",
"message": "Notifications fetched successfully",
"data": [
{
"id": 1,
"title": "Task Approved",
"description": "Your task has been approved",
"type": "task_approval",
"site_activity_id": 123,
"created_on": "2026-10-15 10:30:00"
}
]
}
If no matching notifications are found, the API returns an error status with the message No notifications found.
This endpoint allows the mobile application to retrieve previously stored notification details from the Odoo backend.
Integration with the Flutter Application
The Firebase integration establishes the backend functionality required for push notifications between Odoo and the Center3 mobile application.
The expected interaction between the backend and mobile application is as follows:
- The Flutter application initializes Firebase and obtains the device's FCM token.
- The application sends the token to the Odoo token registration API.
- When a task approval or rejection workflow triggers a notification, Odoo prepares the corresponding notification.
- The backend generates an OAuth 2.0 access token and sends the message to Firebase Cloud Messaging.
- Firebase delivers the notification to the registered device, subject to the device token and delivery conditions.
- The mobile application can read
siteActivityId from the notification's data payload and use it to navigate to the corresponding activity.
- The mobile application can retrieve notification history from Odoo using the notification history API.
The Flutter application is responsible for handling incoming notifications and implementing the appropriate navigation behavior.
Error Handling and Logging
The notification service includes logging and error handling for the main notification-sending operations.
The implementation handles situations such as:
- Missing FCM token for a user.
- Missing Firebase project configuration.
- Missing or invalid service account credentials.
- Failure to generate the OAuth 2.0 access token.
- HTTP request failures when communicating with Firebase.
- Unexpected errors during notification delivery.
Relevant events and errors are logged to help diagnose notification issues.
If a user does not have a registered FCM token, the service does not send the notification. If the Firebase request fails, the service logs the failure and returns an unsuccessful result.
Conclusion
The Firebase integration in Odoo 19 provides a reusable mechanism for sending push notifications from the Center3 backend to the mobile application.
It supports Firebase authentication, FCM token registration, task approval and rejection notifications, structured notification data for activity navigation, and notification history retrieval.
By centralizing notification delivery in a reusable service and maintaining notification records in Odoo, the integration provides a foundation for keeping mobile users informed about task-related updates and accessing their previous notifications.