I am trying to get model records in a dropdown list of Systray Icon.
I am getting a "No enumerator given to foreach" error on button click.
I could see the data on the console as a list of names.
This is my XML file.
<t t-name="test.module.systray.UserMenu.Previews">
<t
<t t-set="previews" t-value="widget.previews"/>
<t
<t t-if="_.isEmpty(previews)">
<li
<li class="text-center o_no_activity mt16">
<span>
<span>No records yet...</span>
</li>
</t>
<t
</li>
</t>
<t t-foreach="previews" t-as="preview">
<t
<t t-esc="preview"/>
</t>
</t>
</t>
</t>
This is my js file
odoo.define('test_module.systray_cloud', function(require) {
"use strict";
var SystrayMenu = require('web.SystrayMenu');
var session = require('web.session');
var Widget = require('web.Widget');
var core = require('web.core');
var QWeb = core.qweb;
var ActionMenu = Widget.extend({
template: 'systray_test.myicon',
events: {
'click .my_icon': '_onActivityMenuShow',
'click .o_mail_activity_action': '_onActivityActionClick',
},
start: function () {
this._$activitiesPreview = this.$('o_test_module_systray_dropdown_items');
this._$previews = this.$('.o_test_module_systray_dropdown_items');
},
_getActivityData: function () {
var self = this;
return self._rpc({
model: 'test.module',
method: 'systray_get_records',
args: [],
kwargs: {context: session.user_context},
}).then(function (data) {
self.previews = data;
});
},
_updateActivityPreview: function () {
var self = this;
self._getActivityData().then(function (){
console.log('In the previews');
self._$activitiesPreview.html(QWeb.render('test.module.systray.UserMenu.Previews', {
widget: self,
}));
});
},
_onActivityMenuShow: function () {
document.body.classList.add('modal-open');
this._updateActivityPreview();
},
});
SystrayMenu.Items.push(ActionMenu);
return ActionMenu;
});