Skip to content

Commit

Permalink
Merge 1e40ff6 into 201df55
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoalf committed Jul 28, 2015
2 parents 201df55 + 1e40ff6 commit 41ea5e8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
#
##############################################################################

from . import (
account_tax_expense_include
)
from . import models
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
""",
'depends': ['base', 'account'],
'data': [
'account_tax_expense_include_view.xml',
'views/account_tax_expense_include_view.xml',
],
'installable': False
'installable': True
}
23 changes: 23 additions & 0 deletions account_tax_expense_include/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
# Copyright (C) 2010 - 2014 Savoir-faire Linux
# (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import account_tax_expense_include
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,33 @@
#
##############################################################################

from openerp.osv import orm, fields
from openerp import models, fields, api
from openerp.tools.float_utils import float_round


class account_tax(orm.Model):
class account_tax(models.Model):
_inherit = 'account.tax'
_columns = {
'expense_include': fields.boolean('Tax Included in Expense',
help="Check this if this tax is \
included in the expense amount."),
}

def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None, force_excluded=False):
expense_include = fields.Boolean('Tax Included in Expense',
help="Check this if this tax is \
included in the expense amount.")

@api.model
def compute_all(
self, taxes, price_unit, quantity, product=None, partner=None,
force_excluded=False):
"""
:param force_excluded: boolean used to say that we don't want to consider the value of field price_include of
tax. It's used in encoding by line where you don't matter if you encoded a tax with that boolean to True or
False
:param force_excluded: boolean used to say that we don't want to
consider the value of field price_include of tax. It's used
in encoding by line where you don't matter if you encoded a tax
with that boolean to True or False
RETURN: {
'total': 0.0, # Total without taxes
'total_included: 0.0, # Total with taxes
'taxes': [] # List of taxes, see compute for the format
'taxes': [] # List of taxes, see compute for
# the format
}
"""

# By default, for each tax, tax amount will first be computed
# and rounded at the 'Account' decimal precision for each
# PO/SO/invoice line and then these rounded amounts will be
Expand All @@ -53,9 +56,11 @@ def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partne
# precision when we round the tax amount for each line (we use
# the 'Account' decimal precision + 5), and that way it's like
# rounding after the sum of the tax amounts of each line
precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
precision = self.env['decimal.precision'].precision_get('Account')
tax_compute_precision = precision
if taxes and taxes[0].company_id.tax_calculation_rounding_method == 'round_globally':
if (taxes and
taxes[0].company_id.tax_calculation_rounding_method ==
'round_globally'):
tax_compute_precision += 5
totalin = totalex = float_round(price_unit * quantity, precision)
tin = []
Expand All @@ -66,7 +71,7 @@ def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partne
else:
tin.append(tax)
tin = self.compute_inv(
cr, uid, tin, price_unit, quantity, product=product,
tin, price_unit, quantity, product=product,
partner=partner, precision=tax_compute_precision
)
for r in tin:
Expand All @@ -77,7 +82,7 @@ def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partne
except:
pass
tex = self._compute(
cr, uid, tex, totlex_qty, quantity, product=product,
tex, totlex_qty, quantity, product=product,
partner=partner, precision=tax_compute_precision
)
for r in tex:
Expand Down

0 comments on commit 41ea5e8

Please sign in to comment.