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

hi in my odoo report for pay slip i want to count total allowance and total deduction in that 

i try with 


 <t t-set="allowance_tot" t-if="p.category_id.name == 'Indemnite' and p.total != ''" t-value="allowance_tot+p.total"/> <t t-set="deduction_tot" t-if="p.category_id.name == 'Deduction' and p.total != ''" t-value="deduction_tot+p.total"/>


and then display as 


<td><t t-esc="deduction_tot or ' '"/></td>

<td><t t-esc="allowance_tot or ' '"/></td>


it gives error like 

TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'


i check value for all but not a single value in blank still it gives error

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

<t t-set="allowance_tot" t-if="p.category_id.name == 'Indemnite' and p.total != ''" t-value="allowance_tot+p.total"/>

here you are adding None+float, allowance_tot has no value.

If you need to set allowance , try these steps:-

<t t-set="allowance" t-value="get_allowance() or 0"/> try to put this code before your loop starts .

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
gru 18
2903
1
sty 18
5922
2
sie 17
7427
0
lip 17
4748
0
maj 17
2620