Merge lp:~openerp-dev/openobject-addons/5.0-opw-17578-rco into lp:openobject-addons/5.0

Proposed by Raphael Collet (OpenERP)
Status: Merged
Merged at revision: 2927
Proposed branch: lp:~openerp-dev/openobject-addons/5.0-opw-17578-rco
Merge into: lp:openobject-addons/5.0
Diff against target: 66 lines (+16/-18)
1 file modified
point_of_sale/pos.py (+16/-18)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/5.0-opw-17578-rco
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+75766@code.launchpad.net

Description of the change

The amounts in the point of sale order were not rounded according to the currency.
This fixes this issue (case: 17578).

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'point_of_sale/pos.py'
2--- point_of_sale/pos.py 2011-09-16 10:31:49 +0000
3+++ point_of_sale/pos.py 2011-09-16 16:03:24 +0000
4@@ -60,37 +60,32 @@
5 return {'value': {'pricelist_id': pricelist}}
6
7 def _amount_total(self, cr, uid, ids, field_name, arg, context):
8- cr.execute("""
9- SELECT
10- p.id,
11- COALESCE(SUM(
12- l.price_unit*l.qty*(1-(l.discount/100.0)))::decimal(16,2), 0
13- ) AS amount
14- FROM pos_order p
15- LEFT OUTER JOIN pos_order_line l ON (p.id=l.order_id)
16- WHERE p.id IN %s GROUP BY p.id """, (tuple(ids),))
17- res = dict(cr.fetchall())
18-
19- for rec in self.browse(cr, uid, ids, context):
20- if rec.partner_id \
21- and rec.partner_id.property_account_position \
22- and rec.partner_id.property_account_position.tax_ids:
23- res[rec.id] = res[rec.id] - rec.amount_tax
24+ res = {}
25+ for order in self.browse(cr, uid, ids, context):
26+ val = 0.0
27+ for line in order.lines:
28+ val += line.price_subtotal
29+ if order.partner_id \
30+ and order.partner_id.property_account_position \
31+ and order.partner_id.property_account_position.tax_ids:
32+ val -= order.amount_tax
33+ res[order.id] = val
34 return res
35
36 def _amount_tax(self, cr, uid, ids, field_name, arg, context):
37 res = {}
38 tax_obj = self.pool.get('account.tax')
39+ cur_obj = self.pool.get('res.currency')
40 for order in self.browse(cr, uid, ids):
41 val = 0.0
42+ cur = order.pricelist_id.currency_id
43 for line in order.lines:
44 val = reduce(lambda x, y: x+round(y['amount'], 2),
45 tax_obj.compute_inv(cr, uid, line.product_id.taxes_id,
46 line.price_unit * \
47 (1-(line.discount or 0.0)/100.0), line.qty),
48 val)
49-
50- res[order.id] = val
51+ res[order.id] = cur_obj.round(cr, uid, cur, val)
52 return res
53
54 def _total_payment(self, cr, uid, ids, field_name, arg, context):
55@@ -817,8 +812,11 @@
56
57 def _amount_line(self, cr, uid, ids, field_name, arg, context):
58 res = {}
59+ cur_obj = self.pool.get('res.currency')
60 for line in self.browse(cr, uid, ids):
61 res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0)
62+ cur = line.order_id.pricelist_id.currency_id
63+ res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
64 return res
65
66 def price_by_product(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False):