Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fix taxes calculation in sale order (issue #1333) #1334

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions sale_order_taxes/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,37 @@
#
##############################################################################

from openerp.osv import osv


class sale_order(osv.osv):
_inherit = 'sale.order'

def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
"""
Compute the total amounts of the SO.
"""
res = {}
for order in self.browse(cr, uid, ids, context=context):
order._calc_taxes()
res[order.id] = {
'amount_untaxed': 0.0,
'amount_tax': 0.0,
'amount_total': 0.0,
}
amount_untaxed = amount_tax = 0.0
for line in order.order_line:
amount_untaxed += line.price_subtotal

for tax in order.taxes:
amount_tax += tax.amount

res[order.id]['amount_untaxed'] = order.pricelist_id.currency_id.round(amount_untaxed)
res[order.id]['amount_tax'] = order.pricelist_id.currency_id.round(amount_tax)
res[order.id]['amount_total'] = amount_untaxed + amount_tax

return res

from openerp import models, fields, api
import openerp.addons.decimal_precision as dp

Expand Down