Merge lp:~openerp-dev/openobject-addons/5.0-opw-18126-ado into lp:openobject-addons/5.0

Proposed by Amit Dodiya (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/5.0-opw-18126-ado
Merge into: lp:openobject-addons/5.0
Diff against target: 141 lines (+51/-12)
4 files modified
account/account.py (+34/-1)
account/invoice.py (+6/-4)
purchase/purchase.py (+5/-3)
sale/sale.py (+6/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/5.0-opw-18126-ado
Reviewer Review Type Date Requested Status
Raphael Collet (OpenERP) Pending
Review via email: mp+79252@code.launchpad.net

Description of the change

Hello,

[FIX] Tax included in price is not working : case(18126)

In Sales order / Account Invoice / Purchase Order when making tax calculations, the amount calculation is wrong. It adds the Tax even if we have checked the "taxes included in the price" in Taxes card.

Thanks,
Amit

To post a comment you must log in.
2927. By Raphael Collet (OpenERP)

[MERGE] opw 17578

2928. By nel

[FIX] when invoic

2929. By nel

[Revert]

2930. By Amit Dodiya (OpenERP)

[FIX] Tax included in price is not working

Unmerged revisions

2930. By Amit Dodiya (OpenERP)

[FIX] Tax included in price is not working

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account/account.py'
--- account/account.py 2011-09-22 12:00:02 +0000
+++ account/account.py 2011-11-15 09:32:34 +0000
@@ -1585,6 +1585,39 @@
1585 cur_price_unit+=amount21585 cur_price_unit+=amount2
1586 return res1586 return res
15871587
1588 def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
1589 """
1590 RETURN: {
1591 'total': 0.0, # Total without taxes
1592 'total_included: 0.0, # Total with taxes
1593 'taxes': [] # List of taxes, see compute for the format
1594 }
1595 """
1596 totalin = totalex = round(price_unit * quantity, int(config['price_accuracy']))
1597 tin = []
1598 tex = []
1599 for tax in taxes:
1600 if tax.price_include:
1601 tin.append(tax)
1602 else:
1603 tex.append(tax)
1604 tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner)
1605 for r in tin:
1606 totalex -= r.get('amount', 0.0)
1607 totlex_qty = 0.0
1608 try:
1609 totlex_qty=totalex/quantity
1610 except:
1611 pass
1612 tex = self.compute(cr, uid, tex, totlex_qty, quantity, address_id=address_id, product=product, partner=partner)
1613 for r in tex:
1614 totalin += r.get('amount', 0.0)
1615 return {
1616 'total': totalex,
1617 'total_included': totalin,
1618 'taxes': tin + tex
1619 }
1620
1588 def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):1621 def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
15891622
1590 """1623 """
@@ -1635,7 +1668,7 @@
1635 elif tax.type=='code':1668 elif tax.type=='code':
1636 address = address_id and self.pool.get('res.partner.address').browse(cr, uid, address_id) or None1669 address = address_id and self.pool.get('res.partner.address').browse(cr, uid, address_id) or None
1637 localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}1670 localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
1638 exec tax.python_compute_inv in localdict1671 exec tax.python_compute in localdict
1639 amount = localdict['result']1672 amount = localdict['result']
1640 elif tax.type=='balance':1673 elif tax.type=='balance':
1641 amount = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0)1674 amount = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0)
16421675
=== modified file 'account/invoice.py'
--- account/invoice.py 2011-09-08 08:35:21 +0000
+++ account/invoice.py 2011-11-15 09:32:34 +0000
@@ -53,8 +53,8 @@
53 }53 }
54 for line in invoice.invoice_line:54 for line in invoice.invoice_line:
55 res[invoice.id]['amount_untaxed'] += line.price_subtotal55 res[invoice.id]['amount_untaxed'] += line.price_subtotal
56 for line in invoice.tax_line:56 for c in self.pool.get('account.tax').compute_all(cr, uid, line.invoice_line_tax_id, line.price_unit, line.quantity, line.product_id)['taxes']:
57 res[invoice.id]['amount_tax'] += line.amount57 res[invoice.id]['amount_tax']+= c.get('amount', 0.0)
58 res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed']58 res[invoice.id]['amount_total'] = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed']
59 return res59 return res
6060
@@ -999,11 +999,13 @@
999 def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict):999 def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict):
1000 res = {}1000 res = {}
1001 cur_obj=self.pool.get('res.currency')1001 cur_obj=self.pool.get('res.currency')
1002 tax_obj = self.pool.get('account.tax')
1002 for line in self.browse(cr, uid, ids):1003 for line in self.browse(cr, uid, ids):
1003 if line.invoice_id:1004 if line.invoice_id:
1004 res[line.id] = line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0)1005 price = line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0)
1005 cur = line.invoice_id.currency_id1006 cur = line.invoice_id.currency_id
1006 res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])1007 taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, line.product_id)
1008 res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
1007 else:1009 else:
1008 res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),int(config['price_accuracy']))1010 res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),int(config['price_accuracy']))
1009 return res1011 return res
10101012
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2011-09-15 09:04:43 +0000
+++ purchase/purchase.py 2011-11-15 09:32:34 +0000
@@ -55,8 +55,8 @@
55 val = val1 = 0.055 val = val1 = 0.0
56 cur=order.pricelist_id.currency_id56 cur=order.pricelist_id.currency_id
57 for line in order.order_line:57 for line in order.order_line:
58 for c in self.pool.get('account.tax').compute(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id, order.partner_id):58 for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id, order.partner_id)['taxes']:
59 val+= c['amount']59 val+= c.get('amount', 0.0)
60 val1 += line.price_subtotal60 val1 += line.price_subtotal
61 res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val)61 res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val)
62 res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1)62 res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1)
@@ -464,9 +464,11 @@
464 def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict):464 def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict):
465 res = {}465 res = {}
466 cur_obj=self.pool.get('res.currency')466 cur_obj=self.pool.get('res.currency')
467 tax_obj = self.pool.get('account.tax')
467 for line in self.browse(cr, uid, ids):468 for line in self.browse(cr, uid, ids):
468 cur = line.order_id.pricelist_id.currency_id469 cur = line.order_id.pricelist_id.currency_id
469 res[line.id] = cur_obj.round(cr, uid, cur, line.price_unit * line.product_qty)470 taxes = tax_obj.compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, line.order_id.partner_address_id.id, line.product_id, line.order_id.partner_id)
471 res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
470 return res472 return res
471473
472 _columns = {474 _columns = {
473475
=== modified file 'sale/sale.py'
--- sale/sale.py 2011-11-10 16:42:32 +0000
+++ sale/sale.py 2011-11-15 09:32:34 +0000
@@ -64,8 +64,8 @@
6464
65 def _amount_line_tax(self, cr, uid, line, context={}):65 def _amount_line_tax(self, cr, uid, line, context={}):
66 val = 0.066 val = 0.0
67 for c in self.pool.get('account.tax').compute(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id):67 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.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)['taxes']:
68 val += c['amount']68 val += c.get('amount', 0.0)
69 return val69 return val
7070
71 def _amount_all(self, cr, uid, ids, field_name, arg, context):71 def _amount_all(self, cr, uid, ids, field_name, arg, context):
@@ -767,10 +767,12 @@
767 def _amount_line(self, cr, uid, ids, field_name, arg, context):767 def _amount_line(self, cr, uid, ids, field_name, arg, context):
768 res = {}768 res = {}
769 cur_obj = self.pool.get('res.currency')769 cur_obj = self.pool.get('res.currency')
770 tax_obj = self.pool.get('account.tax')
770 for line in self.browse(cr, uid, ids):771 for line in self.browse(cr, uid, ids):
771 res[line.id] = line.price_unit * line.product_uom_qty * (1 - (line.discount or 0.0) / 100.0)772 price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
773 taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)
772 cur = line.order_id.pricelist_id.currency_id774 cur = line.order_id.pricelist_id.currency_id
773 res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])775 res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
774 return res776 return res
775777
776 def _number_packages(self, cr, uid, ids, field_name, arg, context):778 def _number_packages(self, cr, uid, ids, field_name, arg, context):