Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I want to show all taxes on sale order.
So i have to connections :
sale.order to sale.order.line : a One2many, with inverse_name = order_id
sale.order.line to account.tax : a Many2many.
My question is how to connect sale.order with account.tax?
Yes I finally found a solution :
In python, I inherit sale.order :
_inherit = 'sale.order'
tabTaxes = fields.Many2many('account.tax', compute='_compute_my_taxe', string='tabTaxes')
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
_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">
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
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):
_res = self._cr.dictfetchall()
if not _res: #To control if it's not empty
myparameter : it will be my ID of sale.order
MYREQUEST_WITH_PARAMETER : it will be my request
_res : it will return a dictionary
But I don't know yet how to handle empty result (if not _res).
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 12/3/15, 10:57 AM|
|Seen: 579 times|
|Last updated: 2/26/16, 10:36 AM|