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

Hi, i am using odoo11.

I wanted to experiment with custom reports for accounting. So I added a special "print invoice griglia" in the print menubar by means of the following code:


<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>        
        <report
            id="custom_invoice_griglia"
            model="account.invoice"
            string="Invoices griglia"
            report_type="qweb-pdf"
            name="custom_invoice.report_invoice_griglia"
            file="custom_invoice.report_invoice_griglia"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            print_report_name="(object._get_printed_report_name())"
        />

         <template id="report_invoice_griglia"> <t t-call="web.html_container"> <t t-foreach="docs" t-as="o"> <t t-call="custom_invoice.report_invoice_griglia" t-lang="o.partner_id.lang"/> </t> </t> </template>
        <template id="report_invoice_griglia"> <t t-if="not o and doc"> <t t-set="o" t-value="doc"/> </t> <t t-if="o and 'company_id' in o"> <t t-set="company" t-value="o.company_id.sudo()"/> </t> <t t-if="not o or not 'company_id' in o"> <t t-set="company" t-value="res_company"/> </t> <t t-call="web.html_container"> <div class="article" style="margin-top:0px;padding-top:0px;"> Hello there </div> </t> </template> </data> </odoo>


And it sorta works: i effectively end up with a blank pdf file containing the "Hello there" string. The only problem is that there's a lot of blank space on top of the page, before the "hello there".

I tried to fix it by merely setting margin and padding of the 'page' tag to zero, but this does not appear to have any affect. I also noticed that if you remove the class="article" attribute, no page is generated and an empty pdf is outputted instead. 

So i tried to find some css rule for "article" by grepping:

grep -rl "\.article" *

but no result is found.

So where does the space at the top of a blank report come from? Is there a way to get rid of it? Thank you very much in advance for any help!

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Ok, maybe I managed to solve (parts of) my own problem. The key is to pass the desired value of data_report_margin_top (which i put in bold in the following snippet)

        <template id="report_invoice_griglia">
            <t t-if="not o and doc">
                <t t-set="o" t-value="doc"/>
            </t>

            <t t-if="o and 'company_id' in o">
                <t t-set="company" t-value="o.company_id.sudo()"/>
            </t>
            <t t-if="not o or not 'company_id' in o">
                <t t-set="company" t-value="res_company"/>
            </t>
            
            
            <t t-call="web.html_container">
              <t t-set="data_report_margin_top" t-value="1"/>
                <div class="article" style="position:absolute; top:0px; ">
                    <div style="background-color: red;">HELLO THERE</div>
                </div>
            </t>
  </template>


For some reason I have to pass 1 because it doesn't appear to work with zero...

In any case it's still a mystery why class="article" is necessary in order to get a non-empty pdf. Who knows?

Also, changing the other margins seems a little more complicated because the html_container doesn't have such fields as input values. Still trying to get it to work.

Cheers.


Ả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 21
2775
4
thg 10 20
10417
1
thg 4 20
4915
0
thg 3 19
2854
1
thg 8 18
6087