I am trying to implement a component which displays in Systray currently running task in timer.timer model (Odoo 15 Enterprise)
I've extended the model to send a payload to trigger an action in the component
class TimerTimer(models.Model):
_inherit = 'timer.timer'
def create(self, vals):
record = super(TimerTimer, self).create(vals)
self.env['bus.bus']._sendone(record.user_id.partner_id, "timer.timer/updated", {})
return record
def write(self, vals):
record = super(TimerTimer, self).write(vals)
self.env['bus.bus']._sendone(self.user_id.partner_id, "timer.timer/updated", {})
return record
I can see the payload incoming to browser via poll request. Now, how to subscribe to it in my component? I've tried this:
class Timer extends Component {
setup() {
let self = this
console.log("EventBus")
console.log(self\.env\.bus\)
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ useBus\(self.env.bus, "timer.timer/updated", event => {
console.log(event)
})
}
Timer.template = "eaxpl_timesheet_timer.Timer"
registry.category("systray").add("eaxpl_timesheet_timer.Timer", { Component: Timer }, { sequence: 3 });
export default Timer
Unfortunately it does not seem to work. The event bus object is there but it does not seem to catch the payload incoming. I have tried listening on:
- timer.timer/updated
- notification
Any hints appreciated