如何自定义发票打印odoo 10

时间:2018-09-11 09:27:05

标签: python odoo odoo-10

我想将自己的发票pdf打印纸自定义为不同于odoo提供的内容,例如这样 enter image description here

1 个答案:

答案 0 :(得分:1)

  1. 如果要修改现有报告而不是继承odoo库。和 使用 xpath 标签进行更改。否则,您还将创建自己的报告 使用xml标签。 示例可能对您有用:

“打印”菜单中的“报告”菜单按钮:

<report
   id="saleorder_quotation_report"
   model="account.invoice"
   string="Print Invoice"
   report_type="qweb-pdf"
   name="module_name.your_report_id"
   file="module_name.your_report_id"
   attachment_use="False"
   />

此处为示例代码:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <template id="put_your_xml_id">
            <t t-call="module_name.external_layout">
                <t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})" />
                <div class="page">
                <div class="col-xs-6" style = "margin-top:15px;">
                    <strong>Invoicing address:</strong>
                    <div t-field="o.partner_id"
                        <!-- Here you make your own code using div and other tags -->
                    </div>
                </div>
            </t>
        </template>
        <template id="your_report_id">
            <t t-call="report.html_container">
                <t t-foreach="docs" t-as="o">
                    <t t-call="module_name.put_your_xml_id" t-lang="o.partner_id.lang"/>
                </t>
            </t>
       </template>
  </data>