From b17fd217bda95a929c895c95fdf238def0a21d04 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 12 Sep 2013 15:07:47 +0200 Subject: [PATCH] [FIX] point_of_sale: correct _get_tax_amount to see several taxes in reports bzr revid: mat@openerp.com-20130912130747-g3mj44w341v8ao2z --- addons/point_of_sale/report/pos_details.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/addons/point_of_sale/report/pos_details.py b/addons/point_of_sale/report/pos_details.py index 3b8df068a34..439371c0a05 100644 --- a/addons/point_of_sale/report/pos_details.py +++ b/addons/point_of_sale/report/pos_details.py @@ -151,24 +151,18 @@ class pos_details(report_sxw.rml_parse): return self._ellipsis(name, maxlen, ' ...') def _get_tax_amount(self, form): - res = {} - temp = {} - list_ids = [] - temp2 = 0.0 + taxes = {} + account_tax_obj = self.pool.get('account.tax') user_ids = form['user_ids'] or self._get_all_users() pos_order_obj = self.pool.get('pos.order') pos_ids = pos_order_obj.search(self.cr, self.uid, [('date_order','>=',form['date_start'] + ' 00:00:00'),('date_order','<=',form['date_end'] + ' 23:59:59'),('state','in',['paid','invoiced','done']),('user_id','in',user_ids)]) - temp.update({'name': ''}) for order in pos_order_obj.browse(self.cr, self.uid, pos_ids): - temp2 += order.amount_tax for line in order.lines: - if len(line.product_id.taxes_id): - tax = line.product_id.taxes_id[0] - res[tax.name] = (line.price_unit * line.qty * (1-(line.discount or 0.0) / 100.0)) + (tax.id in list_ids and res[tax.name] or 0) - list_ids.append(tax.id) - temp.update({'name': tax.name}) - temp.update({'amount': temp2}) - return [temp] or False + line_taxes = account_tax_obj.compute_all(self.cr, self.uid, line.product_id.taxes_id, line.price_unit, line.qty, product=line.product_id, partner=line.order_id.partner_id or False) + for tax in line_taxes['taxes']: + taxes.setdefault(tax['id'], {'name': tax['name'], 'amount':0.0}) + taxes[tax['id']]['amount'] += tax['amount'] + return [value for value in taxes.values()] or False def _get_user_names(self, user_ids): user_obj = self.pool.get('res.users')