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

WIP: [ADD] Migrate module account_tax_expense_include to 8.0 version #72

Open
wants to merge 4 commits into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions account_tax_expense_include/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Taxes included in expense
=========================
This module adds a checkbox to tax to include tax in expense invoices.
It is useful if your taxes are not included in the price, but you
want to ease the life of your employees by allowing them to enter
their expenses with the taxes included.

The tax calculation doesn't work in v7 and v8 for an expense. The expense now
create a voucher that only has one tax rate by voucher and we can't
safely select one tax rate per expense form. To fix this situation the
expense form should suport the taxes like a supplier invoice form and a
the end of the workflow produce a voucher and the journal entries like
what is done when a supplier invoice is open.

Contributors
------------
* Jonatan Cloutier <[email protected]>
* Maxime Chambreuil <[email protected]>
* Sandy Carter <[email protected]>
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
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
Expand All @@ -22,35 +22,14 @@

{
'name': 'Taxes included in expense',
'version': '1.0',
'version': '8.0.1.0.0',
'author': "Savoir-faire Linux,Odoo Community Association (OCA)",
'category': 'Account',
'website': 'http://wwww.savoirfairelinux.com',
'license': 'AGPL-3',
'description': """
Taxes included in expense
=========================
This module adds a checkbox to tax to include tax in expense invoices.
It is useful if your taxes are not included in the price, but you
want to ease the life of your employees by allowing them to enter
their expenses with the taxes included.

The tax calculation doesn't work in v7 and v8 for an expense. The expense now
create a voucher that only has one tax rate by voucher and we can't
safely select one tax rate per expense form. To fix this situation the
expense form should suport the taxes like a supplier invoice form and a
the end of the workflow produce a voucher and the journal entries like
what is done when a supplier invoice is open.

Contributors
------------
* Jonatan Cloutier <[email protected]>
* Maxime Chambreuil <[email protected]>
* Sandy Carter <[email protected]>
""",
'depends': ['base', 'account'],
'depends': ['base', 'account', 'l10n_ca'],
'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
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
Expand All @@ -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 AccountTax(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.multi
def compute_all(
self, 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,20 +56,22 @@ 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 (self and
self[0].company_id.tax_calculation_rounding_method ==
'round_globally'):
tax_compute_precision += 5
totalin = totalex = float_round(price_unit * quantity, precision)
tin = []
tex = []
for tax in taxes:
for tax in self:
if not tax.price_include or force_excluded:
tex.append(tax)
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
8 changes: 7 additions & 1 deletion l10n_ca_account_check_writing/account_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import logging

from openerp import api, models, _

from openerp.tools import config

_logger = logging.getLogger(__name__)
# Odoo's built-in routines for converting numbers to words is pretty bad,
# especially in French This is why we use the library below. You can get it at:
# https://pypi.python.org/pypi/num2words
from num2words import num2words
try:
from num2words import num2words
except (ImportError, IOError) as err:
_logger.debug(err)


class AccountVoucher(models.Model):
Expand Down