Skip to content

Commit

Permalink
[ADD] account_invoice_validate_tax: When validating an invoice, valid…
Browse files Browse the repository at this point in the history
…ate that taxes have been entered on its lines.
  • Loading branch information
alfredoavanzosc committed May 3, 2021
1 parent 2831544 commit 0f9253e
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 0 deletions.
29 changes: 29 additions & 0 deletions account_invoice_validate_tax/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. 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 validate tax
============================

* When validating an invoice, validate that taxes have been entered on its
lines.

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

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

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Contributors
------------

* Ana Juaristi <anajuaristi@avanzosc.es>
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es>
1 change: 1 addition & 0 deletions account_invoice_validate_tax/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions account_invoice_validate_tax/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2021 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Account Invoice Validate Tax",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"author": "AvanzOSC",
"website": "http://www.avanzosc.es",
"category": "Invoicing Management",
"depends": [
"account",
],
"data": [
],
"installable": True,
"auto_install": False,
}
28 changes: 28 additions & 0 deletions account_invoice_validate_tax/i18n/account_invoice_validate_tax.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_validate_tax
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-03 09:18+0000\n"
"PO-Revision-Date: 2021-05-03 09:18+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_invoice_validate_tax
#: model:ir.model,name:account_invoice_validate_tax.model_account_invoice
msgid "Invoice"
msgstr ""

#. module: account_invoice_validate_tax
#: code:addons/account_invoice_validate_tax/models/account_invoice.py:15
#, python-format
msgid "You must introduce tax to the line with description: {}"
msgstr ""

28 changes: 28 additions & 0 deletions account_invoice_validate_tax/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_validate_tax
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-03 09:19+0000\n"
"PO-Revision-Date: 2021-05-03 09:19+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_invoice_validate_tax
#: model:ir.model,name:account_invoice_validate_tax.model_account_invoice
msgid "Invoice"
msgstr "Factura"

#. module: account_invoice_validate_tax
#: code:addons/account_invoice_validate_tax/models/account_invoice.py:15
#, python-format
msgid "You must introduce tax to the line with description: {}"
msgstr "Debe de introducir impuesto en la línea con descripcion: {}"

1 change: 1 addition & 0 deletions account_invoice_validate_tax/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_invoice
18 changes: 18 additions & 0 deletions account_invoice_validate_tax/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2021 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import models, api, _
from odoo.exceptions import ValidationError


class AccountInvoice(models.Model):
_inherit = 'account.invoice'

@api.multi
def action_invoice_open(self):
for invoice in self:
for line in invoice.invoice_line_ids:
if not line.invoice_line_tax_ids:
message = _(u"You must introduce tax to the line with "
"description: {}").format(line.name)
raise ValidationError(message)
return super(AccountInvoice, self).action_invoice_open()
1 change: 1 addition & 0 deletions account_invoice_validate_tax/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_account_invoice_validate_tax
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2021 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo.tests import common
from odoo.exceptions import ValidationError


@common.at_install(False)
@common.post_install(True)
class TestAccountInvoiceValidateTax(common.SavepointCase):

@classmethod
def setUpClass(cls):
super(TestAccountInvoiceValidateTax, cls).setUpClass()
cls.account = cls.env['account.account'].search([], limit=1)
cls.tax = cls.env['account.tax'].search([], limit=1)
cls.partner = cls.env['res.partner'].search([], limit=1)
cls.product = cls.env.ref('product.product_product_3')
invoice_vals = {'name': 'For test account_invoice_validate_tax',
'partner_id': cls.partner.id,
'type': 'out_invoice',
'currency_id': cls.env.ref("base.ARS").id}
line_vals = {
'product_id': cls.product.id,
'name': cls.product.name,
'account_id': cls.account.id,
'quantity': 1,
'price_unit': 800}
invoice_vals['invoice_line_ids'] = [(0, 0, line_vals)]
cls.invoice = cls.env['account.invoice'].create(invoice_vals)

def test_account_invoice_validate_tax(self):
with self.assertRaises(ValidationError):
self.invoice.action_invoice_open()
self.invoice.invoice_line_ids.write(
{'invoice_line_tax_ids': [(6, 0, self.tax.ids)]})
self.invoice.action_invoice_open()
self.assertEquals(self.invoice.state, 'open')

0 comments on commit 0f9253e

Please sign in to comment.