odoo Primal web report [print]

https://www.odoo.com/documentation/12.0/reference/reports.html      specific look at official documents

 

A paper format settings:

<record id="paperformat_frenchcheck" model="report.paperformat"> <field name="name">French Bank Check</field> <field name="default" eval="True"/> <field name="format">custom</field> <field name="page_height">80</field> <field name="page_width">175</field> <field name="orientation">Portrait</field> <field name="margin_top">3</field> <field name="margin_bottom">3</field> <field name="margin_left">3</field> <field name="margin_right">3</field> <field name="header_line" eval="False"/> <field name="header_spacing">3</field> <field name="dpi">80</field> </record>


二、菜单按钮:
  <Report 
attachment_use = "False"
Model = "Product.Product" To print module #
REPORT_TYPE = "Qweb-PDF"
ID = "print_product_menu_barcode"
String = "print bar"
name = "product.print_template_barcode"
    = File "Product. print_template_barcode " Print File #
    paperformat = "product.paperformat_frenchcheck" # print paper format
/>



<img t-att-src="'/report/barcode/QR/%s' % 'My text in qr code'"/> 
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s'%('QR', 'text', 200, 200)"/> 二维码

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <template id="print_template_barcode">
            <t t-call="web.html_container">
                <t t-foreach="docs" t-as="o">
                    <div class="page" style="margin-top:0px">
                        <style type="text/css">
                            .gxtr >th{
                            text-align:center;
                            border-top: 1px solid #000;
                            border-left: 1px solid #000;
                            border-bottom: 1px solid #000;
                            <!--background-color:#BEBEBE;-->
                            font-size:14px;
                            }
                            .gxtr >td{
                            border-bottom: 1px solid #000;
                            border-left: 1px solid #000;
                            border-right: 1px solid #000;
                            font-size:20px;
                            display: flex;
                            <!--text-align :center;-->
                            }
                            .gxtr >tr{
                            border-bottom: 1px solid #000;
                            border-left: 1px solid #000;
                            border-right: 1px solid #000;
                            font-size:20px;
                            display: flex;
                            text-align :center;
                            }
                            .herdtd{
                            word-wrap:break-word;width:22%;font-size:14px;
                            }
                            .gxdiv{border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid
                            #000;font-size:14px;}
                        </style>
                        <t t-call="web.basic_layout">
                             <table width="279" border="1">
                                <thead>
                                <tr>
                                    <td>名称</td>
                                    <td>
                                        <span t-field="o.name"/>
                                    </td>
                                    <td rowspan="3">
<t-to-srcimg                                        ="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s'%('QR', o.barcode, 100, 100)"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td>价格</td>
                                    <td>
                                        <span t-field="o.list_price"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td>代码</td>
                                    <td >
                                        <span t-field="o.barcode"/>
                                    </td>
                                </tr>
                                 <tr class="gxtr">
                                        <th>TH</Test. 1>
                                        <th colspan="2">测试值</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr t-foreach="o.attribute_line_ids" t-as="att" class="gxtr">
                                        <td height="32" style="text-align :center;">
                                            <span t-field="att.attribute_id.name"/>
                                        </td>
                                        <td colspan="2"  style="text-align :center;">
                                            <t t-foreach="att.value_ids" t-as="val">
                                                <span t-field="val.name"/>;
                                            </t>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </t>
                    </div>
                </t>
            </t>
        </template>
    </ odoo</>Data
>

 

 

 

Guess you like

Origin www.cnblogs.com/1314520xh/p/12443834.html