Skip to Content
Menu
This question has been flagged

Hi,

Even with many tries, actually having issue to generate a block of HTML from a report when a button in the view is clicked.

On the Javascript side :

var rpc = require('web.rpc');
Var FormController = require('web.FormController');
FormController.include({
     _gen_html: function() {
        this._rpc({
            model: "product.template",
            method: 'my_method',
        }).then(function(result){
            // Things to do with response ...
        });


On the Python side :

class MyClass(models.Model):

@api.model
 def my_method(self):
        docargs = {
            "id": self.id,
        }
        #self.ensure_one()
        template = self.env['ir.actions.report'].search([('report_name', '=', "test_report")], limit=1).render_qweb_html(self, docargs)
        return template


The intention is to get a report from a specific view, a product or user or customer, don't care from which model it is because this button can be placed everywhere. Then it must generate an HTML block , like a report from an existing report with the information on the actual element based on the ID. The report itself is correct when seeing it with a standard method, but in this test the only response received by the RPC query is a minimal page with header / footer / body, but nothing in the page content.


@


Avatar
Discard
Related Posts Replies Views Activity
1
Aug 23
384
0
Mar 23
1084
2
Jan 23
3639
0
Feb 21
2476
0
Mar 15
202