简体   繁体   中英

Odoo 10 custom Qweb report page design

I've created my custom report and which has more than 1 page. You can imagine that each page has a table. And table can have 10 row in a page, if rows are more than 10, rows go second page. By the way, other table slides to half of page. But I want to all tables should start the top of the page in any case. If there is 14 row in the first table, the second table must start the third page. I wrote a condition in python like;

extrapage = fields.Boolean(compute="function") 
def function():
if row >=10:
    extrapage = True

and view.xml

<t
t-if="o.extrapage"
<div style="height:29cm;width:20cm;"></div>
</t>

but i dont want to make like this, must be some professional way. Can you help me to do? Thank you.

Please follow and use the below code in the Qweb Template View

Let assume that o is your purchase order and I will try to break the page when my purchase order line having more than 10 records.

<tr t-foreach="o.order_line" t-as="line">

    <t t-if="line_index+1 == 10">
        <p style="page-break-after:always;"/>
    </t>
</tr>

Attributes :

=> o : purchase order object

=> order_line : is the purchase order line

=> _index : its special attribute in the qweb template which is help to count the interaction record inside line object.

I hope my answer may helpful for you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM