Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
8615 Widoki

I found this old thread discussing the same question:

https://www.odoo.com/forum/help-1/question/hide-discounts-on-order-lines-on-quotations-invoices-16510

However, the solution suggested is outdated and doesn't apply to the new QWeb-based reporting engine. I just wondered, if there is a better/easier solution by now to automatically determine, whether the "discount" column should be displayed or not. Also, it would be nice to hide the discount in an invoice line, if there is none given or it is negative.

Awatar
Odrzuć
Najlepsza odpowiedź

Modifications in Qweb report:


..... 
<t t-set="is_discount" t-value="0"/>
<t t-foreach="o.invoice_line" t-as="l">
<t t-if="l.discount"><t t-set="is_discount" t-value="1"/></t>
</t>
<t t-if="is_discount">
<th class="text-right" groups="sale.group_discount_per_so_line">Discount (%)</th>
</t>
.....
<t t-if="is_discount">
<td class="text-right" groups="sale.group_discount_per_so_line"><span t-field="l.discount"/></td>
</t>

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Sorry for the wait, I didn't have time until now to test the propsed solution.

With the answer of zbik pointing me in the direction, but the proposed solution not working, i had to modify it in two places to get it working:

<t t-set="is_discount" t-value="False"/>
<!-- This is important, otherwise is_discount will only be visible inside the foreach-loop and be undefined thereafter -->

<t t-foreach="o.order_line" t-as="l">
<t t-if="l.discount"><t t-set="is_discount" t-value="True"/></t>
</t>

<!-- Table headers -->
<t t-if="is_discount">
<th class="text-right">Discount</th>
</t>


<!-- Actual table row -->
<t t-if="is_discount"> <!-- Instead of l.discount, otherwise there is a cell missing and following columns will be shifted -->
<td class="text-right" groups="sale.group_discount_per_so_line"><t t-if="l.discount"><span t-field="l.discount"/>&#160;%</t></td>
</t>

Which works very well altogether now.

PS: Sorry for posting this as answer, my karma doesn't allow me to comment yet :(

Awatar
Odrzuć

Yes you are right,

Powiązane posty Odpowiedzi Widoki Czynność
2
gru 24
7208
1
sty 23
8532
1
paź 22
4069
1
lut 22
4672
3
lip 19
5762