I want to add a "show more comments .." button to my section | openerp module

I work in one of | openerp module. However, in my module, the comments section displays all comments on the page. So I wanted to add a button to show more comments .

Here is my content view :

<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:

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 the corresponding method :

@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

      

Short description:

If N number of comments appears on the page, then by default they are displayed by default. But I want to control the flow in the "show more comments" section. So how can this be done in my model.py, I don't know how to deal with it.

10 comments should be loaded in each click.

Thanks for any help | offers in advance

+3


source to share


1 answer


$('.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 jsonrpc method

0


source







All Articles