-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_invoice_validate_tax: When validating an invoice, valid…
…ate that taxes have been entered on its lines.
- Loading branch information
1 parent
2831544
commit 0f9253e
Showing
9 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
28
account_invoice_validate_tax/i18n/account_invoice_validate_tax.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_invoice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_account_invoice_validate_tax |
37 changes: 37 additions & 0 deletions
37
account_invoice_validate_tax/tests/test_account_invoice_validate_tax.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |