Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
150 Zobrazení

Hi,

I have inserted new columns into the pdf quote

  • Now two of the other coloumns are not printing correctly.
  • I also need to get the numbers all looking the same, besides the discount column.

https://ibb.co/C5kcZGMK


Current Code:

<data>

  <data>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/div" meta-class="oe_structure">

      <br/>

    </xpath>

  </data>

  <data>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/div[3]" meta-class="oe_structure">

      <br/>

    </xpath>

  </data>

  <data>

    <xpath position="replace" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/table/thead/tr/th[@name='th_taxes']" meta-name="th_taxes" meta-class="text-end"/>

    <xpath position="after" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/table/thead/tr/th[@name='th_discount']" meta-name="th_discount" meta-t-if="display_discount" meta-class="text-end">

      <th class="text-center"> Price Excl

      </th>

      <th name="th_taxes" class="text-center">VAT</th>

    </xpath>

  </data>

  <data>

    <xpath position="replace" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//th[@name='th_quantity']" meta-name="th_quantity" meta-class="text-end">

      <th name="th_quantity" class="text-end" style="text-align: center;">Qty</th>

    </xpath>

  </data>

  <data>

    <xpath position="replace" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//th[@name='th_subtotal']/span"/>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//th[@name='th_subtotal']" meta-name="th_subtotal" meta-class="text-end">

      <span class="text-center">Price Incl</span>

      <br/>

    </xpath>

  </data>

  <data>

    <xpath position="replace" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/table/tbody/t[2]/tr/t/td[@name='td_quantity']" meta-name="td_quantity" meta-class="text-end text-nowrap"/>

    <xpath position="after" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/table/tbody/t[2]/tr/t/td[@name='td_name']" meta-name="td_name">

      <td name="td_quantity" class="text-center">

        <p>

          <span t-field="line.product_uom_qty"/>

        </p>

        <xpath position="after" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/table/tbody/t[2]/tr/t/td[@name='td_quantity'][2]/span[3]" meta-t-if="line.product_uom_id != line.product_id.uom_id" meta-class="text-center"/>

      </td>

    </xpath>

    <xpath position="after" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/table/tbody/t[2]/tr/t/td[@name='td_discount']" meta-name="td_discount" meta-t-if="display_discount" meta-class="text-center">

      <td>

        <p>

          <span t-field="line.price_reduce_taxexcl"/>

        </p>

      </td>

    </xpath>

  </data>

  <data>

    <xpath position="replace" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//td[@name='td_priceunit']/span[@t-field='line.price_unit']" meta-t-field="line.price_unit"/>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//td[@name='td_priceunit']" meta-name="td_priceunit" meta-class="text-end ">

      <p><span class="text-end" t-field="line.price_unit"/></p>

    </xpath>

  </data>

  <data>

    <xpath position="replace" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//td[@name='td_taxes']/span" meta-t-out="taxes"/>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//td[@name='td_taxes']" meta-name="td_taxes" meta-t-attf-class="text-center {{ 'text-nowrap' if len(taxes) &lt; 10 else '' }}">

      <p t-out="taxes">Tax 15%</p>

      <p class="text-end"><span t-field="line.price_tax"/></p>

    </xpath>

  </data>

  <data>

    <xpath position="attributes" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//td[@name='td_section_line']" meta-name="td_section_line" meta-colspan="99">

      <attribute name="colspan">100</attribute>

    </xpath>

  </data>

  <data>

    <xpath position="attributes" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//td[@name='td_note_line']" meta-name="td_note_line" meta-colspan="99">

      <attribute name="colspan">100</attribute>

    </xpath>

  </data>

  <data>

    <xpath position="attributes" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']//td[@name='td_section_subtotal']" meta-name="td_section_subtotal" meta-colspan="99">

      <attribute name="colspan">100</attribute>

    </xpath>

  </data>

  <data>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/div[5]" meta-class="oe_structure">

      <br/>

    </xpath>

  </data>

  <data>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/div[9]/div" meta-class="oe_structure">

      <br/>

    </xpath>

  </data>

  <data>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/div[10]/div" meta-class="oe_structure">

      <br/>

    </xpath>

  </data>

  <data>

    <xpath position="inside" expr="/t[@t-name='sale.report_saleorder_document_copy_1']//t[@t-call='web.external_layout']/div/div[11]" meta-class="oe_structure">

      <br/>

    </xpath>

  </data>

</data>

Avatar
Zrušit
Nejlepší odpověď

Hi,


* Use text-center, text-end, or utility classes like col-x (width) to align content.

        <th class="text-center col-2">Price Excl</th>


* To render numeric expressions cleanly and consistently, replace t-field or t-out with:

           <span t-esc="line.price_unit * (1 - (line.discount or 0.0) / 100.0)" />


* Define Column Widths and Avoid Replacing Incorrect Nodes.

- Rather than replacing generic tags, target the correct sale order report template:

              - Inherit from sale.report_saleorder_document (not its copy).

              - Modify existing <th name="th_quantity">, <td name="td_priceunit">, etc.


Try the following code.


<odoo>

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


    <!-- Modify Table Headers -->

    <xpath expr="//thead/tr/th[@name='th_discount']" position="after">

      <th class="text-end" name="th_price_excl">Price Excl</th>

      <th class="text-end" name="th_tax">VAT</th>

    </xpath>


    <!-- Quantity Column -->

    <xpath expr="//th[@name='th_quantity']" position="attributes">

      <attribute name="class">text-end</attribute>

    </xpath>

    <xpath expr="//td[@name='td_quantity']" position="attributes">

      <attribute name="class">text-end</attribute>

    </xpath>


    <!-- Modify Table Data Rows: Add Price Excl and Tax -->

    <xpath expr="//td[@name='td_discount']" position="after">

      <td class="text-end" name="td_price_excl">

        <span t-esc="line.price_reduce_taxexcl"/>

      </td>

      <td class="text-end" name="td_tax">

        <span t-field="line.price_tax"/>

      </td>

    </xpath>


    <!-- Format Price Unit -->

    <xpath expr="//td[@name='td_priceunit']" position="replace">

      <td class="text-end" name="td_priceunit">

        <span t-esc="line.price_unit"/>

      </td>

    </xpath>


    <!-- Optional: Format subtotal for consistency -->

    <xpath expr="//td[@name='td_subtotal']" position="replace">

      <td class="text-end" name="td_subtotal">

        <span t-esc="line.price_total"/>

      </td>

    </xpath>


  </template>

</odoo>


* Ensure that the inherited template is correct.



Hope it helps.

Avatar
Zrušit
Autor

Thank you so much. This helped with the spacing.

https://ibb.co/JY687qw

How can I
- format the "Unit Price" & "Vat" (not the percentage) values to all look like the "Price Excl" value
- Calculate the discount amount and show it (similar to the "VAT" coloumn)
- Change the "Qty" to integer

Autor Nejlepší odpověď

I also want to adjust the heading

https://ibb.co/5g7MRrBk

I want to move the red section to under the "Quotation" heading to the right of the customer details.

Avatar
Zrušit
Nejlepší odpověď

Hi,

Adds Price Excl and VAT columns after Discount

Ensures column counts between <thead> and <tbody> match

Formats all prices and numbers consistently using t-field

Aligns all numeric columns to the right with text-end

Avoids duplicated fields or broken nesting

please try this code 
<odoo>

    <data>


        <!-- HEADER: Add new columns after 'Discount' -->

        <xpath expr="//thead/tr/th[@name='th_discount']" position="after">

            <th class="text-end">Price Excl</th>

            <th class="text-end">VAT</th>

        </xpath>


        <!-- LINE ITEMS: Add matching <td> for new columns -->

        <xpath expr="//tbody//td[@name='td_discount']" position="after">

            <td class="text-end">

                <span t-field="line.price_reduce_taxexcl"/>

            </td>

            <td class="text-end">

                <span t-field="line.price_tax"/>

            </td>

        </xpath>


        <!-- QUANTITY COLUMN: Center align -->

        <xpath expr="//th[@name='th_quantity']" position="replace">

            <th name="th_quantity" class="text-center">Qty</th>

        </xpath>


        <xpath expr="//td[@name='td_quantity']" position="replace">

            <td name="td_quantity" class="text-center">

                <span t-field="line.product_uom_qty"/>

            </td>

        </xpath>


        <!-- PRICE UNIT COLUMN: Format properly -->

        <xpath expr="//td[@name='td_priceunit']" position="replace">

            <td name="td_priceunit" class="text-end">

                <span t-field="line.price_unit"/>

            </td>

        </xpath>


        <!-- SUBTOTAL / PRICE INCL COLUMN: Update header and value -->

        <xpath expr="//th[@name='th_subtotal']/span" position="replace"/>

        <xpath expr="//th[@name='th_subtotal']" position="inside">

            <span class="text-end">Price Incl</span>

        </xpath>


        <xpath expr="//td[@name='td_subtotal']" position="replace">

            <td name="td_subtotal" class="text-end">

                <span t-field="line.price_total"/>

            </td>

        </xpath>


        <!-- OPTIONAL: Ensure colspan is high enough for notes and sections -->

        <xpath expr="//td[@name='td_section_line']" position="attributes">

            <attribute name="colspan">100</attribute>

        </xpath>


        <xpath expr="//td[@name='td_note_line']" position="attributes">

            <attribute name="colspan">100</attribute>

        </xpath>


        <xpath expr="//td[@name='td_section_subtotal']" position="attributes">

            <attribute name="colspan">100</attribute>

        </xpath>


    </data>

</odoo>


i hope it is usefull

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
srp 25
1489
1
čvc 25
565
0
srp 25
482
1
čvn 25
890
1
kvě 25
988