I want to notify whenever one 'comment' is added in backend to any sale order. To do some actions in the website (I have created one view to show sale orders information).
This is mi code:
@api.model
def create(self, values):
if values.get('model') == 'sale.order' and values.get('message_type') == 'comment':
channel = (self._cr.dbname, 'sale.order', 3)
messages = {'type': 'user_notification', 'title': 'Notifiy User'}
self.env['bus.bus'].sendone(channel, messages)
return super(MailMessage, self).create(values)
And I added the channel before like this:
class UserPortalBusController(BusController):
def _poll(self, dbname, channels, last, options):
"""Add the relevant channels to the BusController polling."""
if request.session.uid:
channels = list(channels)
channels.append((request.db, 'sale.order', 3))
return super(UserPortalBusController, self)._poll(dbname, channels, last, options)
When I add one message to sale order I am having this error:
File "/usr/lib/python3/dist-packages/odoo/api.py", line 394, in _model_create_single return self.browse().concat(*(create(self, vals) for vals in arg)) File "/usr/lib/python3/dist-packages/odoo/api.py", line 394, in return self.browse().concat(*(create(self, vals) for vals in arg)) File "/mnt/addons_bp/user_portal/models/mail_message.py", line 18, in create self.env['bus.bus'].sendone(channel, messages) Exception The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/http.py", line 644, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/usr/lib/python3/dist-packages/odoo/http.py", line 302, in _handle_exception raise exception.with_traceback(None) from new_cause AttributeError: 'bus.bus' object has no attribute 'sendone'
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
1
Beantwoorden
4993
Weergaven
If you are using Odoo 15, then you have to use _sendone not sendone and you have to pass three parameters (channel, notification_type and message)
Thanks, you are right. I was using odoo15 but I had not update since a lot. Now all sendone changed to _sendone.
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden