Odoo Help


[V9] How do I show all taxes on a Sales Order? Connecting sale.order and account.tax??

on 12/3/15, 10:57 AM 930 views


I want to show all taxes on sale order.

So i have to connections :

  1. sale.order to sale.order.line : a One2many, with inverse_name = order_id

  2. sale.order.line to account.tax : a Many2many.

My question is how to connect sale.order with account.tax?

Thank you.

On 2/26/16, 10:34 AM

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')


def _compute_my_taxe(self):

maliste = []

for obj in self.order_line:

for taxe in obj.tax_id:


self.tabTaxes = list(maliste)


def get_amount(self, taxeNom):

total = 0

for ligne in self.order_line:

for taxe in ligne.tax_id:

if (taxeNom == taxe.name):


total += ligne.price_reduce * (taxe.amount / 100.)


total += 0

return "{0:.2f}".format(total)

  •   _compute_my_taxe : to get list of my taxes.

  • get_amount : to get amount of that taxes.

Then in my report xml :

<t t-foreach="doc.tabTaxes" t-as="v">



<span t-esc="v.name"/>



<span t-esc="doc.get_amount(v.name)[0]"/>




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 :


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 :


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]

        • myparameter : it will be my ID of sale.order  

        • MYREQUEST_WITH_PARAMETER : it will be my request

        • _res[0] : it will return a dictionary

        But I don't know yet how to handle empty result (if not _res).

        On 2/11/16, 5:50 AM

        Have you found a solution ?

        About This Community

        This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


        Odoo Training Center

        Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

        Test it now

        Question tools

        1 follower(s)


        Asked: 12/3/15, 10:57 AM
        Seen: 930 times
        Last updated: 2/26/16, 10:36 AM