I have a problem with my piece of code in order to get subtotals in sale orders :
[CODE]
import openerp
from openerp import fields, api
from openerp.models import Model
from openerp import _
class tax_line(Model):
_name = "sale.order.line"
_inherit = "sale.order.line"
tax_price = fields.Float(compute='_compute')
taxed_price = fields.Float(compute='_compute')
tax_line = fields.Float(compute='_compute')
taxed_line = fields.Float(compute='_compute')
@api.multi
@api.depends('product_uom_qty', 'price_unit', 'price_subtotal', 'product_id', 'tax_id', 'order_id.partner_id', 'discount')
def _compute(self):
price = self.price_unit * (1 + (self.discount or 0.0)) / 100.0
self.tax_price = self.env["account.tax"].compute_all(self.tax_id, price, self.product_uom_qty, self.product_id, self.order_id.partner_id)['taxes']
self.taxed_price = 0.0
self.tax_line = 0.0
self.taxed_line = 0.0
[/CODE]
[CODE] File "/opt/odoo80/odoo80-server/openerp/fields.py", line 751, in __get__
self.determine_value(record)
File "/opt/odoo80/odoo80-server/openerp/fields.py", line 855, in determine_value
self.compute_value(recs)
File "/opt/odoo80/odoo80-server/openerp/fields.py", line 811, in compute_value
self._compute_value(records)
File "/opt/odoo80/odoo80-server/openerp/fields.py", line 803, in _compute_value
self.compute(records)
File "/opt/odoo80/odoo80-server/openerp/api.py", line 235, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo80/custom/addons/tax_line/tax_line.py", line 27, in _compute
self.tax_price = self.env["account.tax"].compute_all(self.tax_id, price, self.product_uom_qty, self.product_id, self.order_id.partner_id)['taxes']
File "/opt/odoo80/odoo80-server/openerp/api.py", line 235, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo80/odoo80-server/addons/account/account.py", line 2120, in compute_all
product=product, partner=partner, force_excluded=force_excluded)
File "/opt/odoo80/odoo80-server/openerp/api.py", line 237, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo80/odoo80-server/addons/account/account.py", line 2091, in compute_all
totalin = totalex = round(price_unit * quantity, precision)
QWebException: ""unsupported operand type(s) for *: 'account.tax' and 'float'" while evaluating
'l.tax_price'" while evaluating
"translate_doc(doc_id, doc_model, 'partner_id.lang', 'sale.report_saleorder_document')"[/CODE]
My XML Report just implement the new fields and there is no problem if i do something in my .py code like self.tax_price = self.price_unit
Thanks for your help!