Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4657 Lượt xem

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.


@


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 23
384
0
thg 3 23
1789
2
thg 1 23
5277
0
thg 2 21
3414
0
thg 3 15
554