I am working in one of the odoo | openerp module. However in my module comments section displays all the comments on page. So i wanted to add show more comment button.
Here is my view content:
<button class="btn mt8 oe_button">Show more...</button>
My model: py file
class Comment(models.Model):
_name = 'page.comment'
_comments_per_list = 10
relevant comment field in my model is:
website_message_ids = fields.One2many(
'mail.message', 'res_id',
domain=lambda self: [('model', '=', self._name), ('type', '=', 'comment')],
string='Website Messages', help="Website communication history")
and relevant method is :
@api.multi
def get_comment_detail(self):
try:
comments = self.website_message_ids
values.update({
'channel': self.channel_id,
'user': user,
'comments': comments,
})
return values
Brief Description:
If a page gets N number of comments than it shows all of them by default. But I want to control my flow under "show more comments". So, how can it be done within my model.py, I don't know how to deal with it.
On each click, count of 10 comment should be load.
Thanks for Any Help | suggestions in advance
$('.load_comments').on('click', function () {
openerp.jsonRpc("/slides/expand_comment", + $(this).attr('slide-id'), 'call', {
'values': comments,
}).then(function (data) {
$(data.target).closest('.list_comment').html($('<div class="media"</div>'));
// slides: data
});
});
try above jsonrpc method