跳至内容
Odoo 菜单
  • 登录
  • 免费试用
  • 应用程序
    财务
    • 会计
    • 发票
    • 费用
    • 电子表格 (BI)
    • 文档
    • 电子签名
    销售
    • 客户关系管理
    • 销售
    • POS 销售点管理-零售
    • POS 销售点管理 - 餐厅
    • 订阅
    • 租赁
    网站
    • 网站设计
    • 电子商务
    • 博客
    • 论坛
    • 在线客服
    • 在线学习
    供应链
    • 库存
    • 制造
    • 产品生命周期
    • 采购
    • 维护保养
    • 品控
    人力资源
    • 员工
    • 招聘
    • 休假
    • 评价
    • 内部推荐
    • 车队
    营销
    • 社媒营销
    • 电邮营销
    • 短信营销
    • 近期活动
    • 营销自动化
    • 网上调查
    服务
    • 项目管理
    • 工时单
    • 现场服务
    • 服务台
    • 排期
    • 预约
    生产力
    • 讨论
    • 批核
    • IoT物联网
    • VoIP
    • 知识库
    • WhatsApp
    第三方应用软件 Odoo 定制 Odoo云端平台
  • 行业
    零售
    • 书店
    • 服装店
    • 家具店
    • 食品杂货店
    • 五金店
    • 玩具店
    餐饮与酒店服务
    • 酒吧及酒馆
    • 餐厅
    • 快餐
    • 民宿
    • 饮品分销商
    • 酒店
    房地产
    • 房地产代理
    • 建筑师事务所
    • 建造业
    • 地产管理
    • 园艺
    • 业主协会
    咨询
    • 会计师事务所
    • Odoo合作伙伴
    • 市场推广公司
    • 律师事务所
    • 人才招聘
    • 审核 & 认证
    制造
    • 纺织
    • 金属
    • 家具
    • 食品
    • 啤酒厂
    • 企业礼品
    保健与健身
    • 体育俱乐部
    • 眼镜店
    • 健身中心
    • 健康从业者
    • 药房
    • 发型屋
    商贸服务
    • 维修人员
    • IT 硬件及支持
    • 太阳能系统
    • 鞋匠
    • 清洁服务
    • 暖通空调服务
    其他
    • 非营利组织
    • 环境机构
    • 广告牌租赁
    • 摄影服务
    • 自行车租赁
    • 软件经销商
    浏览所有行业
  • 社区
    学习
    • 教学视频
    • 文档
    • 认证
    • 培训
    • 博客
    • 播客
    赋能教育
    • 教育计划
    • Scale Up! 商业游戏
    • 参观Odoo
    获取软件
    • 下载
    • 版本对比
    • 发布
    合作
    • Github
    • 论坛
    • 近期活动
    • 翻译
    • 成为合作伙伴
    • 合作伙伴服务
    • 注册您的会计事务所
    获取服务
    • 寻找合作伙伴
    • 查找会计服务
    • 预约顾问咨询
    • 安装及推行服务
    • 客户参考
    • 支持
    • 升级
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    获取演示
  • 定价
  • 技术支持

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • 客户关系管理
  • e-Commerce
  • 会计
  • 库存
  • PoS
  • 项目
  • MRP
All apps
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
只限注册用戶才可与社群互动。
所有帖文 人 徽章
标签 (查看所有)
odoo accounting v14 pos v15
关于此论坛区
帮助

Odoo Online 18 - Adding Custom field to invoice PDF

订阅

此帖文有活动时,接收通知

此问题已终结
2 回复
3748 查看
形象
Fai Ala

Hello, 


We have Odoo Online 18. With Odoo Studio. We went to the invoicing module, customized the draft/invoice form to include an integer field by drag and drop plus another text field. On the form it appears, but on the invoice PDF either the final one (invoice) or draft, it doesn't appear. We need your help to insert the correct code and show it on the PDF file. 


New Edit: 

When on the invoice page, we clicked the Odoo Studio icon at the top right. It opened the customization page, then we found Reports button which we clicked. It showed us all sorts of reports. One is called "PDF" which represents the final invoice and one is called "PDF Without Payment" which represents the draft invoice. 


This is the internal code of the page: 


<t t-name="account.report_invoice_document">
            <t t-call="web.external_layout">
                <t t-set="o" t-value="o.with_context(lang=lang)"/>
                <t t-set="forced_vat" t-value="o.fiscal_position_id.foreign_vat"/> <!-- So that it appears in the footer of the report instead of the company VAT if it's set -->
                <div class="row">
                    <t t-if="o.partner_shipping_id and (o.partner_shipping_id != o.partner_id)">
                        <div class="col-6">
                            <t t-set="information_block">
                                <div groups="account.group_delivery_invoice_address" name="shipping_address_block">
                                    <strong>Shipping Address</strong>
                                    <div t-field="o.partner_shipping_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>
                                </div>
                            </t>
                        </div>
                        <div class="col-6" name="address_not_same_as_shipping">
                            <t t-set="address">
                                <address class="mb-0" t-field="o.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>
                                <div t-if="o.partner_id.vat" id="partner_vat_address_not_same_as_shipping">
                                    <t t-if="o.company_id.account_fiscal_country_id.vat_label" t-out="o.company_id.account_fiscal_country_id.vat_label" id="inv_tax_id_label"/>
                                    <t t-else="">Tax ID</t>: <span t-field="o.partner_id.vat"/>
                                </div>
                            </t>
                        </div>
                    </t>
                    <t t-elif="o.partner_shipping_id and (o.partner_shipping_id == o.partner_id)">
                        <div class="offset-col-6 col-6" name="address_same_as_shipping">
                            <t t-set="address">
                                <address class="mb-0" t-field="o.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>
                                <div t-if="o.partner_id.vat" id="partner_vat_address_same_as_shipping">
                                    <t t-if="o.company_id.account_fiscal_country_id.vat_label" t-out="o.company_id.account_fiscal_country_id.vat_label" id="inv_tax_id_label"/>
                                    <t t-else="">Tax ID</t>: <span t-field="o.partner_id.vat"/>
                                </div>
                            </t>
                        </div>
                    </t>
                    <t t-else="">
                        <div class="offset-col-6 col-6" name="no_shipping">
                            <t t-set="address">
                                <address class="mb-0" t-field="o.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>
                                <div t-if="o.partner_id.vat" id="partner_vat_no_shipping">
                                    <t t-if="o.company_id.account_fiscal_country_id.vat_label" t-out="o.company_id.account_fiscal_country_id.vat_label" id="inv_tax_id_label"/>
                                    <t t-else="">Tax ID</t>: <span t-field="o.partner_id.vat"/>
                                </div>
                            </t>
                        </div>
                    </t>
                </div>
                <div class="clearfix invoice_main">
                    <div class="page mb-4">
                        <t t-set="layout_document_title">
                            <span t-if="not proforma"/>
                            <span t-else="">PROFORMA</span>
                            <span t-if="o.move_type == 'out_invoice' and o.state == 'posted'">Invoice</span>
                            <span t-elif="o.move_type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
                            <span t-elif="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>
                            <span t-elif="o.move_type == 'out_refund' and o.state == 'posted'">Credit Note</span>
                            <span t-elif="o.move_type == 'out_refund' and o.state == 'draft'">Draft Credit Note</span>
                            <span t-elif="o.move_type == 'out_refund' and o.state == 'cancel'">Cancelled Credit Note</span>
                            <span t-elif="o.move_type == 'in_refund'">Vendor Credit Note</span>
                            <span t-elif="o.move_type == 'in_invoice'">Vendor Bill</span>
                            <span t-if="o.name != '/'" t-field="o.name">INV/2023/0001</span>
                        </t>
                        <div class="oe_structure"/>
                        <div id="informations" class="row mb-4">
                            <div class="col" t-if="o.invoice_date" name="invoice_date">
                                <t t-if="o.move_type == 'out_invoice'"><strong>Invoice Date</strong></t>
                                <t t-elif="o.move_type == 'out_refund'"><strong>Credit Note Date</strong></t>
                                <t t-elif="o.move_type == 'out_receipt'"><strong>Receipt Date</strong></t>
                                <t t-else=""><strong>Date</strong></t>
                                <div t-field="o.invoice_date">2023-09-12</div>
                            </div>
                            <div class="col" t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'" name="due_date">
                                <strong>Due Date</strong>
                                <div t-field="o.invoice_date_due">2023-10-31</div>
                            </div>
                            <div class="col" t-if="o.delivery_date" name="delivery_date">
                                <strong>Delivery Date</strong>
                                <div t-field="o.delivery_date">2023-09-25</div>
                            </div>
                            <div class="col" t-if="o.invoice_origin" name="origin">
                                <strong>Source</strong>
                                <div t-field="o.invoice_origin">SO123</div>
                            </div>
                            <div class="col" t-if="o.partner_id.ref" name="customer_code">
                                <strong>Customer Code</strong>
                                <div t-field="o.partner_id.ref"/>
                            </div>
                            <div class="col" t-if="o.ref" name="reference">
                                <strong>Reference</strong>
                                <div t-field="o.ref">INV/2023/00001</div>
                            </div>
                            <div class="col" t-if="o.invoice_incoterm_id" name="incoterm_id">
                                <strong>Incoterm</strong>
                                <div t-if="o.incoterm_location">
                                    <span t-field="o.invoice_incoterm_id.code"/> <br/>
                                    <span t-field="o.incoterm_location"/>
                                </div>
                                <div t-else="" t-field="o.invoice_incoterm_id.code" class="m-0"/>
                            </div>
                        </div>

                        <t t-set="display_discount" t-value="any(l.discount for l in o.invoice_line_ids)"/>
                        <div class="oe_structure"/>
                        <table class="o_has_total_table table o_main_table table-borderless" name="invoice_line_table">
                            <thead>
                                <tr>
                                    <th name="th_description" class="text-start"><span>Description</span></th>
                                    <th name="th_quantity" class="text-end"><span>Quantity</span></th>
                                    <th name="th_priceunit" t-attf-class="text-end text-nowrap {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Unit Price</span></th>
                                    <th name="th_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
                                        <span>Disc.%</span>
                                    </th>
                                    <th name="th_taxes" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th>
                                    <th name="th_subtotal" class="text-end">
                                        <span>Amount</span>
                                    </th>
                                </tr>
                            </thead>
                            <tbody class="invoice_tbody">
                                <t t-set="current_subtotal" t-value="0"/>
                                <t t-set="current_total" t-value="0"/>
                                <t t-set="lines" t-value="o.invoice_line_ids.sorted(key=lambda l: (-l.sequence, l.date, l.move_name, -l.id), reverse=True)"/>

                                <t t-foreach="lines" t-as="line">
                                    <t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
                                    <t t-set="current_total" t-value="current_total + line.price_total"/>

                                    <tr t-att-class="'fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
                                        <t t-if="line.display_type == 'product'" name="account_invoice_line_accountable">
                                            <td name="account_invoice_line_name">
                                                <span t-if="line.name" t-field="line.name" t-options="{'widget': 'text'}">Bacon Burger</span>
                                            </td>
                                            <td name="td_quantity" class="text-end text-nowrap">
                                                <span t-field="line.quantity">3.00</span>
                                                <span t-field="line.product_uom_id" groups="uom.group_uom">units</span>
                                            </td>
                                            <td name="td_price_unit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
                                                <span class="text-nowrap" t-field="line.price_unit">9.00</span>
                                            </td>
                                            <td name="td_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
                                                <span class="text-nowrap" t-field="line.discount">0</span>
                                            </td>
                                            <t t-set="taxes" t-value="', '.join([(tax.invoice_label or tax.name) for tax in line.tax_ids])"/>
                                            <td name="td_taxes" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }} {{ 'text-nowrap' if len(taxes) &lt; 10 else '' }}">
                                                <span t-out="taxes" id="line_tax_ids">Tax 15%</span>
                                            </td>
                                            <td name="td_subtotal" class="text-end o_price_total">
                                                <span class="text-nowrap" t-field="line.price_subtotal">27.00</span>
                                            </td>
                                        </t>
                                        <t t-elif="line.display_type == 'line_section'">
                                            <td colspan="99">
                                                <span t-field="line.name" t-options="{'widget': 'text'}">A section title</span>
                                            </td>
                                            <t t-set="current_section" t-value="line"/>
                                            <t t-set="current_subtotal" t-value="0"/>
                                        </t>
                                        <t t-elif="line.display_type == 'line_note'">
                                            <td colspan="99">
                                                <span t-field="line.name" t-options="{'widget': 'text'}">A note, whose content usually applies to the section or product above.</span>
                                            </td>
                                        </t>
                                    </tr>

                                    <t t-if="current_section and (line_last or lines[line_index+1].display_type == 'line_section')">
                                        <tr class="is-subtotal text-end">
                                            <td colspan="99">
                                                <strong class="mr16">Subtotal</strong>
                                                <span t-out="current_subtotal" t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}">31.05</span>
                                            </td>
                                        </tr>
                                    </t>
                                </t>
                            </tbody>
                        </table>
                        <div>
                            <div id="right-elements" t-attf-class="#{'col-5' if report_type != 'html' else 'col-12 col-md-5'} ms-5 d-inline-block float-end">
                                <div id="total" class="clearfix row mt-n3">
                                    <div class="ms-auto">
                                        <table class="o_total_table table table-borderless avoid-page-break-inside">

                                            <!-- Tax totals summary (invoice currency) -->
                                            <t t-if="o.tax_totals" t-call="account.document_tax_totals">
                                                <t t-set="tax_totals" t-value="o.tax_totals"/>
                                                <t t-set="currency" t-value="o.currency_id"/>
                                            </t>

                                            <!--Payments-->
                                            <t t-if="print_with_payments">
                                                <t t-if="o.payment_state != 'invoicing_legacy'">
                                                    <t t-set="payments_vals" t-value="o.sudo().invoice_payments_widget and o.sudo().invoice_payments_widget['content'] or []"/>
                                                    <t t-foreach="payments_vals" t-as="payment_vals">
                                                        <tr t-if="payment_vals['is_exchange'] == 0">
                                                            <td>
                                                                <i class="oe_form_field text-end oe_payment_label">Paid on <t t-out="payment_vals['date']" t-options="{&quot;widget&quot;: &quot;date&quot;}">2021-09-19</t></i>
                                                            </td>
                                                            <td class="text-end">
                                                                <span t-out="payment_vals['amount']" t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}">20.00</span>
                                                            </td>
                                                        </tr>
                                                    </t>
                                                    <t t-if="len(payments_vals) &gt; 0">
                                                        <tr class="fw-bold">
                                                            <td>Amount Due</td>
                                                            <td class="text-end">
                                                                <span t-field="o.amount_residual">11.05</span>
                                                            </td>
                                                        </tr>
                                                    </t>
                                                </t>
                                            </t>
                                        </table>
                                    </div>
                                </div>
                                <div class="mb-2">
                                    <p class="text-end lh-sm" t-if="o.company_id.display_invoice_amount_total_words">
                                        Total amount in words: <br/>
                                        <small class="text-muted lh-sm"><span t-field="o.amount_total_words">Thirty one dollar and Five cents</span></small>
                                    </p>
                                </div>

                                <!-- Tax totals summary (company currency) -->
                                <t t-if="o.tax_totals.get('display_in_company_currency')">
                                    <t t-set="tax_totals" t-value="o.tax_totals"/>
                                    <t t-call="account.document_tax_totals_company_currency_template"/>
                                </t>
                                <t t-else="">
                                    <div class="oe_structure"/>
                                </t>
                            </div>
                            <div id="payment_term" class="clearfix">
                                <div class="justify-text">
                                    <p t-if="not is_html_empty(o.fiscal_position_id.note)" name="note" class="mb-2">
                                        <span t-field="o.fiscal_position_id.note"/>
                                    </p>
                                </div>
                                <div class="justify-text">
                                    <p t-if="not is_html_empty(o.taxes_legal_notes)" name="taxes_legal_notes" class="mb-2">
                                        <span t-field="o.taxes_legal_notes"/>
                                    </p>
                                </div>
                                <t t-set="payment_term_details" t-value="o.payment_term_details"/>
                                <div class="mb-3">
                                    <span id="payment_terms_note_id" t-if="o.invoice_payment_term_id.note" t-field="o.invoice_payment_term_id.note" name="payment_term">Payment within 30 calendar day</span><br/>
                                    <t t-if="o.invoice_payment_term_id.display_on_invoice and payment_term_details">
                                        <div t-if="o.show_payment_term_details" id="total_payment_term_details_table" class="row">
                                            <div t-attf-class="#{'col-10' if report_type != 'html' else 'col-sm-10 col-md-9'}">
                                                <t t-if="o._is_eligible_for_early_payment_discount(o.currency_id,o.invoice_date)">
                                                    <td>
                                                        <span t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}" t-out="o.invoice_payment_term_id._get_amount_due_after_discount(o.amount_total, o.amount_tax)">30.00</span> due if paid before
                                                        <span t-out="o.invoice_payment_term_id._get_last_discount_date_formatted(o.invoice_date)">2024-01-01</span>
                                                    </td>
                                                </t>
                                                <t t-if="len(payment_term_details) &gt; 1" t-foreach="payment_term_details" t-as="term">
                                                    <div>
                                                        <span t-out="term_index + 1">1</span> - Installment of
                                                        <t t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: o.currency_id}" t-out="term.get('amount')" class="text-end">31.05</t>
                                                        <span> due on </span>
                                                        <t t-out="term.get('date')" class="text-start">2024-01-01</t>
                                                    </div>
                                                </t>
                                            </div>
                                        </div>
                                    </t>
                                </div>
                                <div class="mb-3" t-if="o.move_type in ('out_invoice', 'in_refund') and o.payment_reference">
                                    <p name="payment_communication">
                                        Payment Communication: <span class="fw-bold" t-field="o.payment_reference">INV/2023/00001</span>
                                        <t t-if="o.partner_bank_id">
                                            <br/> on this account: <span t-field="o.partner_bank_id" class="fw-bold"/>
                                        </t>
                                    </p>
                                </div>
                                <t t-set="show_qr" t-value="o.display_qr_code and o.amount_residual &gt; 0"/>
                                <div t-if="not show_qr" name="qr_code_placeholder" class="oe_structure"/>
                                <div id="qrcode" class="d-flex mb-3 avoid-page-break-inside" t-else="">
                                    <div class="qrcode me-3" id="qrcode_image">
                                        <t t-set="qr_code_url" t-value="o._generate_qr_code(silent_errors=True)"/>
                                        <p t-if="qr_code_url" class="position-relative mb-0">
                                            <img t-att-src="qr_code_url"/>
                                            <img src="/account/static/src/img/Odoo_logo_O.svg" id="qrcode_odoo_logo" class="top-50 start-50 position-absolute bg-white border border-white border-3 rounded-circle"/>
                                        </p>
                                    </div>
                                    <div class="d-inline text-muted lh-sm fst-italic" id="qrcode_info" t-if="qr_code_url">
                                        <p>Scan this QR Code with<br/>your banking application</p>
                                    </div>
                                </div>
                                <!--terms and conditions-->
                                <div class="text-muted mb-3" t-attf-style="#{'text-align:justify;text-justify:inter-word;' if o.company_id.terms_type != 'html' else ''}" t-if="not is_html_empty(o.narration)" name="comment">
                                    <span t-field="o.narration"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </t>
        </t>

Thanks. 

0
形象
丢弃
形象
Christoph Farnleitner
最佳答案

"PDF Without Payment" doesn't represent a draft invoice, any invoice not yet posted is a draft invoice. It's just a different report you can print, where the difference is simply that one visualizes customer payments, the other one doesn't. So while there is no customer payment yet, both reports should look exactly the same.

Apart from that, the source you've posted does not include any x_studio...-something field, hence, it doesn't do much to your question. Studio customizations create an inherited view (listed in a tab named like that) in the original view. If there is none, you simply haven't added the field there yet.

I'd suggest you're taking a look at https://www.odoo.com/slides/31

1
形象
丢弃
形象
Cybrosys Techno Solutions Pvt.Ltd
最佳答案

Hi,

Open the invoice PDF report in Odoo Studio (PDF or PDF Without Payment).Identify your custom field names (something like x_my_integer and x_my_text).Insert them into the report template using this code:


<div class="row mb-3" name="custom_fields">

    <t t-if="o.x_my_integer">

        <div class="col">

            <strong>My Integer Field:</strong>

            <span t-field="o.x_my_integer"/>

        </div>

    </t>

    <t t-if="o.x_my_text">

        <div class="col">

            <strong>My Text Field:</strong>

            <span t-field="o.x_my_text"/>

        </div>

    </t>

</div>


Hope it helps.

0
形象
丢弃
喜欢讨论吗?不要只阅读,加入进来!

立即创建账户,享受专属功能,与我们的精彩社区互动!

注册
社区
  • 教学视频
  • 文档
  • 论坛
开源
  • 下载
  • Github
  • Runbot
  • 翻译
服务
  • Odoo.sh 托管
  • 支持
  • 升级
  • 自定义开发服务
  • 教育
  • 查找会计服务
  • 寻找合作伙伴
  • 成为合作伙伴
关于我们
  • 我们的公司
  • 品牌资产
  • 联系我们
  • 招聘
  • 近期活动
  • 播客
  • 博客
  • 客户
  • 法律 • 隐私
  • 安全
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo致力于为企业管理提供高效智能的开源解决方案,是全球业内高速成长的软件服务商之一,逾七百五十万用户选择Odoo进行数字化升级。通过一系列全业务链覆盖、高度集成、简单易用的商业应用,助力企业实现信息化改革、降本增效并释放公司增长潜力。

Odoo独特的价值在于是一款非常容易使用又完全集成的应用。

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now