콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
344 화면

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
681
1
9월 25
542
2
8월 25
799
3
8월 25
1011
3
8월 25
2145