diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 52738b1cf8b..d26f9ac0f41 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -47,7 +47,12 @@ class sale_order(osv.osv): def _amount_line_tax(self, cr, uid, line, context=None): val = 0.0 - for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.product_id, line.order_id.partner_id)['taxes']: + line_obj = self.pool['sale.order.line'] + price = line_obj._calc_line_base_price(cr, uid, line, context=context) + qty = line_obj._calc_line_quantity(cr, uid, line, context=context) + for c in self.pool['account.tax'].compute_all( + cr, uid, line.tax_id, price, qty, line.product_id, + line.order_id.partner_id)['taxes']: val += c.get('amount', 0.0) return val @@ -852,6 +857,12 @@ class sale_order_line(osv.osv): return True return False + def _calc_line_base_price(self, cr, uid, line, context=None): + return line.price_unit * (1 - (line.discount or 0.0) / 100.0) + + def _calc_line_quantity(self, cr, uid, line, context=None): + return line.product_uom_qty + def _amount_line(self, cr, uid, ids, field_name, arg, context=None): tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') @@ -859,8 +870,11 @@ class sale_order_line(osv.osv): if context is None: context = {} for line in self.browse(cr, uid, ids, context=context): - price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) - taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id) + price = self._calc_line_base_price(cr, uid, line, context=context) + qty = self._calc_line_quantity(cr, uid, line, context=context) + taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, qty, + line.product_id, + line.order_id.partner_id) cur = line.order_id.pricelist_id.currency_id res[line.id] = cur_obj.round(cr, uid, cur, taxes['total']) return res