Need Help: Odoo 16 Lead Transfer Module - Notifications & Activity Logging Not Working
Current Situation
I have created a custom lead transfer module in Odoo 16 for transferring leads between sales team members. The basic transfer functionality works, but I'm facing issues with notifications and activity logging.
## Current Code
My current implementation:
```python
class LeadTransferWizard(models.TransientModel):
_name = 'lead.transfer.wizard'
_description = 'Lead Transfer Wizard'
lead_id = fields.Many2one('crm.lead', string='Lead', required=True)
user_id = fields.Many2one('res.users', string='Transfer To', required=True)
note = fields.Text(string='Note')
def action_transfer(self):
self.ensure_one()
lead = self.lead_id
try:
# Update lead
lead.write({
'transferred_to_user_id': lead.id,
'res_model_id': self.env['ir.model']._get('crm.lead').id,
})
# Post note in chatter
lead.message_post(
body=_('Lead transferred to %s') % self.user_id.name,
message_type='notification',
subtype_xmlid='mail.mt_note'
)
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'message': _('Lead transferred successfully'),
'type': 'success',
}
}
except Exception as e:
lead.write({'transfer_lead_status': 'draft'})
raise UserError(_('Failed to transfer lead: %s') % str(e))
```
## Issues I'm Facing
1. **Notification Problems:**
- Users are not getting desktop notifications when leads are assigned to them
- Need popup notifications with sound alerts
- Want the notifications to be more visible and attention-grabbing
2. **Activity Logging Issues:**
- Activity timestamps are not being logged properly
- No priority system for transferred leads
- Can't track precise transfer times
## What I Need
1. **Notification Requirements:**
- Desktop notifications with sound
- Browser popup notifications
- Real-time alerts when leads are transferred
- Notifications should include:
* Lead name
* Priority
* Sender information
* Quick action buttons (if possible)
2. **Activity Logging Requirements:**
- Precise timestamps for all transfer actions
- Priority-based due dates
- Complete activity history
- Proper tracking of all lead movements
## Technical Details
- Odoo Version: 16.0
- Modules installed:
* CRM
* Bus
- Browser: Chrome/Firefox (latest versions)
## Questions
1. What's the correct way to implement browser notifications in Odoo 16?
2. How can I add sound to the notifications?
3. What's the best approach for accurate activity timestamp logging?
4. How can I implement a priority system for transferred leads?
5. Is there a way to make notifications persistent until acknowledged?
## What I've Tried
1. Attempted to use bus.bus for notifications:
```python
self.env['bus.bus']._sendone(
self.user_id.partner_id,
'lead.transfer',
{'message': 'New lead assigned'}
)
```
But this doesn't seem to trigger any notifications.
2. Tried adding sound:
```javascript
var audio = new Audio('/path/to/sound.mp3');
audio.play();
```
But couldn't get it working in the Odoo environment.
## Additional Information
- The basic lead transfer functionality works fine
- Users have appropriate access rights
- Browser notifications are enabled
- No JavaScript errors in console
- Server logs show no errors
Any help or guidance would be greatly appreciated. Thank you in advance!