Hello YannCopp,
Yes I finally found a solution :
In python, I inherit sale.order :
class Sale_order(models.Model):
_inherit = 'sale.order'
tabTaxes = fields.Many2many('account.tax', compute='_compute_my_taxe', string='tabTaxes')
@api.multi
def _compute_my_taxe(self):
maliste = []
for obj in self.order_line:
for taxe in obj.tax_id:
maliste.append(taxe.id)
self.tabTaxes = list(maliste)
@api.one
def get_amount(self, taxeNom):
total = 0
for ligne in self.order_line:
for taxe in ligne.tax_id:
if (taxeNom == taxe.name):
try:
total += ligne.price_reduce * (taxe.amount / 100.)
except:
total += 0
return "{0:.2f}".format(total)
Then in my report xml :
<t t-foreach="doc.tabTaxes" t-as="v">
<tr>
<td>
<span t-esc="v.name"/>
</td>
<td>
<span t-esc="doc.get_amount(v.name)[0]"/>
</td>
</tr>
</t>
But I think I'll try using dictionnaries, like I did here : http://stackoverflow.com/questions/34122439/odooqwebdictionary-foreach-print-key-and-value/35655404
And if I wouldn't able to connect sale.order.line with account_tax, I'll use request SQL :
SELECT *
FROM sale_order_line a
,account_tax_sale_order_line_rel b
,account_tax c
WHERE a.id = b.sale_order_line_id
AND b.account_tax_id = c.id
And I'll adapt my request with :
@api.one
def get_taxes(self, myparameter):
self._cr.execute("""<MYREQUEST_WITH_PARAMETER>=%s""", (myparameter,))
_res = self._cr.dictfetchall()
if not _res: #To control if it's not empty
return #???
return _res[0]
Where
But I don't know yet how to handle empty result (if not _res).