summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoffin Simon <sig@odoo.com>2015-05-20 11:30:49 +0200
committerGoffin Simon <sig@odoo.com>2015-06-16 16:04:36 +0200
commit9c30ba7143846b0f9e82140fb33e4ee7dea9435c (patch)
treebad795da513dbc54c9ae36f7321cbb5c6a226084
parent98a72a2604bb8932d5e51e91fab031509a41632c (diff)
[FIX] point_of_sale: sum of pos.order.line
amount_line_tax must be used to compute the _amount_all. In this way, the taxes are computed by "compute_all" which takes into account how to round(globally or per line). Inspired from "sale.order" behaviour. Fixes #6765 opw:640211
-rw-r--r--addons/point_of_sale/point_of_sale.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py
index c64f7fedc58..357c332f6ea 100644
--- a/addons/point_of_sale/point_of_sale.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -557,6 +557,16 @@ class pos_order(osv.osv):
_description = "Point of Sale"
_order = "id desc"
+ def _amount_line_tax(self, cr, uid, line, context=None):
+ account_tax_obj = self.pool['account.tax']
+ taxes_ids = [tax for tax in line.product_id.taxes_id if tax.company_id.id == line.order_id.company_id.id]
+ price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
+ taxes = account_tax_obj.compute_all(cr, uid, taxes_ids, price, line.qty, product=line.product_id, partner=line.order_id.partner_id or False)['taxes']
+ val = 0.0
+ for c in taxes:
+ val += c.get('amount', 0.0)
+ return val
+
def _order_fields(self, cr, uid, ui_order, context=None):
return {
'name': ui_order['name'],
@@ -676,10 +686,10 @@ class pos_order(osv.osv):
res[order.id]['amount_paid'] += payment.amount
res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0)
for line in order.lines:
- val1 += line.price_subtotal_incl
+ val1 += self._amount_line_tax(cr, uid, line, context=context)
val2 += line.price_subtotal
- res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val1-val2)
- res[order.id]['amount_total'] = cur_obj.round(cr, uid, cur, val1)
+ res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val1)
+ res[order.id]['amount_total'] = cur_obj.round(cr, uid, cur, val1+val2)
return res
_columns = {
@@ -1294,8 +1304,8 @@ class pos_order_line(osv.osv):
taxes = account_tax_obj.compute_all(cr, uid, taxes_ids, price, line.qty, product=line.product_id, partner=line.order_id.partner_id or False)
cur = line.order_id.pricelist_id.currency_id
- res[line.id]['price_subtotal'] = cur_obj.round(cr, uid, cur, taxes['total'])
- res[line.id]['price_subtotal_incl'] = cur_obj.round(cr, uid, cur, taxes['total_included'])
+ res[line.id]['price_subtotal'] = taxes['total']
+ res[line.id]['price_subtotal_incl'] = taxes['total_included']
return res
def onchange_product_id(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False, context=None):