Skip to content

Commit

Permalink
[MIG] Migration of the module account_invoice_tax_required based on t…
Browse files Browse the repository at this point in the history
…he PR#404 from Angel Moya
  • Loading branch information
Sylvain Van Hoof committed Mar 21, 2017
1 parent d9667f9 commit ec98029
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 92 deletions.
41 changes: 31 additions & 10 deletions account_invoice_tax_required/README.rst
@@ -1,19 +1,37 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

==================================================
Account invoice with tax required in invoice line
==================================================

This module adds functional a check on invoice
to force user to set tax on invoice line.

Usage
=====

To use this module, you need to:

#. Go to Accounting (or Invoicing) > Sales > Customer Invoices.
#. Create a new invoice.
#. Insert a new invoice line without taxes.
#. Press on "Validate".
#. An error will raise preventing to do it.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/92/9.0


Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
`here <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_invoice_tax_required%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/account-financial-tools/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======
Expand All @@ -22,17 +40,20 @@ Contributors
------------

* Vincent Renaville <vincent.renaville@camptocamp.com>
* Angel Moya <odoo@tecnativa.com>
* Sylvain Van Hoof <sylvain@okia.be>

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
22 changes: 4 additions & 18 deletions account_invoice_tax_required/__init__.py
@@ -1,20 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Vincent Renaville. Copyright 2015 Camptocamp SA
#
# 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/>.
#
##############################################################################
# Copyright 2015 - Camptocamp SA - Author Vincent Renaville
# Copyright 2016 - Tecnativa - Angel Moya <odoo@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
27 changes: 6 additions & 21 deletions account_invoice_tax_required/__manifest__.py
@@ -1,31 +1,16 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Vincent Renaville. Copyright 2015 Camptocamp SA
#
# 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/>.
#
##############################################################################
# Copyright 2015 - Camptocamp SA - Author Vincent Renaville
# Copyright 2016 - Tecnativa - Angel Moya <odoo@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Tax required in invoice",
'version': "8.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
'version': "10.0.1.0.0",
"author": "Camptocamp,Tecnativa,Odoo Community Association (OCA), Okia",
'website': "http://www.camptocamp.com",
'category': "Localisation / Accounting",
'license': "AGPL-3",
'depends': ["account"],
'data': [
],
'installable': False,
'installable': True,
}
22 changes: 4 additions & 18 deletions account_invoice_tax_required/models/__init__.py
@@ -1,20 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Vincent Renaville. Copyright 2015 Camptocamp SA
#
# 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/>.
#
##############################################################################
# Copyright 2015 - Camptocamp SA - Author Vincent Renaville
# Copyright 2016 - Tecnativa - Angel Moya <odoo@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_invoice
36 changes: 11 additions & 25 deletions account_invoice_tax_required/models/account_invoice.py
@@ -1,22 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Vincent Renaville. Copyright 2015 Camptocamp SA
#
# 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/>.
#
##############################################################################
# Copyright 2015 - Camptocamp SA - Author Vincent Renaville
# Copyright 2016 - Tecnativa - Angel Moya <odoo@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, api, exceptions, _


Expand All @@ -27,15 +13,15 @@ class AccountInvoice(models.Model):
def test_invoice_line_tax(self):
errors = []
error_template = _("Invoice has a line with product %s with no taxes")
for invoice in self:
for invoice_line in invoice.invoice_line:
if not invoice_line.invoice_line_tax_id:
error_string = error_template % (invoice_line.name)
errors.append(error_string)
for invoice_line in self.mapped('invoice_line_ids'):
if not invoice_line.invoice_line_tax_ids:
error_string = error_template % (invoice_line.name)
errors.append(error_string)
if errors:
errors_full_string = ','.join(x for x in errors)
raise exceptions.Warning(_('No Taxes Defined!'),
errors_full_string)
raise exceptions.Warning(
_('No Taxes Defined!\n %s') % (errors_full_string)
)
else:
return True

Expand Down
6 changes: 6 additions & 0 deletions account_invoice_tax_required/tests/__init__.py
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2015 - Camptocamp SA - Author Vincent Renaville
# Copyright 2016 - Tecnativa - Angel Moya <odoo@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_account_invoice_tax_required
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
# Copyright 2016 - Tecnativa - Angel Moya <odoo@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp.tests.common import TransactionCase
from openerp import exceptions


class TestAccountInvoiceTaxRequired(TransactionCase):

def setUp(self):
super(TestAccountInvoiceTaxRequired, self).setUp()

self.account_invoice = self.env['account.invoice']
self.account_journal = self.env['account.journal']
self.journal = self.account_journal.create({
'code': 'test',
'name': 'test',
'type': 'sale'
})
self.partner = self.env.ref('base.default_user_res_partner')
account_user_type = self.env.ref(
'account.data_account_type_receivable')

self.account_account = self.env['account.account']
self.account_rec1_id = self.account_account.create(dict(
code="cust_acc",
name="customer account",
user_type_id=account_user_type.id,
reconcile=True,
))

invoice_line_data = [(0, 0, {
'quantity': 10.0,
'account_id': self.account_account.search(
[('user_type_id',
'=',
self.env.ref('account.data_account_type_revenue').id)
], limit=1).id,
'name': 'product test 5',
'price_unit': 100.00,
})]

self.invoice = self.account_invoice.create(dict(
name="Test Customer Invoice",
reference_type="none",
journal_id=self.journal.id,
partner_id=self.partner.id,
account_id=self.account_rec1_id.id,
invoice_line_ids=invoice_line_data
))

def test_exception(self):
"""Validate invoice without tax must raise exception
"""
with self.assertRaises(exceptions.Warning):
self.invoice.action_invoice_open()

0 comments on commit ec98029

Please sign in to comment.