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

Hi,

i want generate a PDF with bar char in odoo 15.

can i help me?

https://miro.medium.com/max/1400/1*bFUKtr4h4mzmY5uHuEz_zA.png

I want print this graph in PDF report but don't have find a documentation or example for include in pdf.


is there anyone to help me or show some example?

thanks a lot 

Ảnh đại diện
Huỷ bỏ

Hello, did you find any solution?

Câu trả lời hay nhất

Hi,

If you are using the content by passing a js file try to use rpc or Ajax call and try to update the current value (add all values with classes)  in a variable
I'd just added an example for a chart view, you can use your own div and table classes of the bar/ any graphical representation

Js:

$.ajax({
                url: '/get/parent/child',
                type: 'POST',
                data: JSON.stringify(result[0]),
                success: function (value) {
                        $('#o_parent_employee').append(value);
                        self.parent = value
                        },
            });
 if we added all classes values in a variable and you can use the value through the controller
Controller:

@http.route('/org_chart', type='http', auth='user', method=['POST'],
                csrf=False)
    def organizational_chart(self, **post):
        parent = post.get('parent')
        data = {'parent': parent}
        context = {'active_model': 'organizational.report',
                   'landscape': 'True'},
        pdf, _ = request.env.ref(
            'module_name.action_report_organizational_chart').with_context(
            landscape=True)._render_qweb_pdf(data=data)
        pdfhttpheaders = [('Content-Type', 'application/pdf'),
                          ('Content-Length', len(pdf))]
        return request.make_response(pdf, headers=pdfhttpheaders)


XML:

<record id="action_report_organizational_chart" model="ir.actions.report">
 
  <field name="name">Organizational chart</field>
<field name="model">organizational.report</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">module_name.organizational_chart_report</field>
<field name="paperformat_id" ref="paper_format_org_chart"/>// you can add the paper format here
</record>

<template id="organizational_chart_report">
    <t t-call="web.html_container">
        <t t-call="web.internal_layout">
            <h2><center>
                <span>Organizational Chart</span>
            </center></h2><br/>
            <br/>
            <center>
                <t t-raw="parent"/>
            </center>
        </t>
    </t>
</template>


if you do not need a controller or js files, you can directly pass the div chat main class through the variable


Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 9 19
3865
1
thg 11 24
1712
0
thg 8 24
1685
2
thg 11 23
3753
5
thg 8 23
9974