跳至內容
選單
此問題已被標幟
3 回覆
312 瀏覽次數

We work for many companies where we have different buyers so we would want the buyer on the quotation.

I added a field to sale order to select the specific contact person (x_partner_contact_id) that is shown in the form view and where we can select the right contact person.

 I want to print this contact information on pdf of sales order. I created an inherited view of the sale order report with xpath as following, but it's not showing on pdf...

<xpath expr="//p[span[@t-field='doc.partner_id.vat']]" position="after">

  <t t-if="doc.x_partner_contact_id">

    <p class="mb-0">

      <strong>Contactpersoon:</strong>

      <span t-field="doc.x_partner_contact_id.name"/>

      <t t-if="doc.x_partner_contact_id.email"> – <span t-field="doc.x_partner_contact_id.email"/></t>

      <t t-if="doc.x_partner_contact_id.phone"> – <span t-field="doc.x_partner_contact_id.phone"/></t>

    </p>

Thank you!

頭像
捨棄
作者

I'm not looking for the sales person (is indeed there), but the buyer at the customer side. Odoo support suggests using 'delivery or invoice' address, but that is not really what I want. I want a field: contact with the name or e-mail of my contact person...

作者 最佳答案

I tried the xpath with customer block, but there is none, this is the original architecture:

<t t-call="web.external_layout">

        <t t-set="doc" t-value="doc.with_context(lang=doc.partner_id.lang)"/>

        <t t-set="forced_vat" t-value="doc.fiscal_position_id.foreign_vat"/> <!-- So that it appears in the footer of the report instead of the company VAT if it's set -->

        <t t-set="address">

            <div t-field="doc.partner_id" class="mb-0" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>

            <p t-if="doc.partner_id.vat" class="mb-0">

                <t t-if="doc.company_id.account_fiscal_country_id.vat_label" t-out="doc.company_id.account_fiscal_country_id.vat_label"/>

                <t t-else="">Tax ID</t>: <span t-field="doc.partner_id.vat"/>

In what block should I insert?

頭像
捨棄
最佳答案

Hi,


Your code is correct in logic, but the issue is that your XPath is probably not matching anything in the quotation template. In some Odoo versions, the VAT field isn’t displayed, so the expression doesn’t find a target. A better anchor is the customer block (//div[@name='customer']).


Also make sure your custom field x_partner_contact_id is a stored Many2one to res.partner, and that you’ve upgraded your module or cleared cached reports after editing. Updating your XPath to the customer block will allow the buyer contact details to show correctly on the PDF.


<template id="report_saleorder_buyer_contact" inherit_id="sale.report_saleorder_document">

    <xpath expr="//div[@name='customer']" position="inside">

        <t t-if="doc.x_partner_contact_id">

            <p class="mb-0">

                <strong>Contactpersoon:</strong>

                <span t-field="doc.x_partner_contact_id.name"/>

                <t t-if="doc.x_partner_contact_id.email"> – <span t-field="doc.x_partner_contact_id.email"/></t>

                <t t-if="doc.x_partner_contact_id.phone"> – <span t-field="doc.x_partner_contact_id.phone"/></t>

            </p>

        </t>

    </xpath>

</template>


Hope it helps

頭像
捨棄
最佳答案

The Quotation PDF already shows the Salesperson selected:


Form View:


PDF:

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
8月 25
663
1
9月 25
529
2
8月 25
792
3
8月 25
989
3
8月 25
2109