Skip to Content
Menu
This question has been flagged
3 Replies
422 Zobrazenia

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!

Avatar
Zrušiť
Autor

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...

Autor Best Answer

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?

Avatar
Zrušiť
Best Answer

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

Avatar
Zrušiť
Best Answer

The Quotation PDF already shows the Salesperson selected:


Form View:


PDF:

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
2
aug 25
750
1
sep 25
720
2
aug 25
909
3
aug 25
1198
3
aug 25
2284