From e0adcc81b717bab8611233c403ac7a0697a8965e Mon Sep 17 00:00:00 2001 From: Kitti U Date: Tue, 16 May 2017 23:22:39 +0700 Subject: [PATCH] [MIG] account_tax_invoice_required: Migrated to 10.0 --- account_invoice_tax_required/README.rst | 3 ++- account_invoice_tax_required/__manifest__.py | 2 +- .../models/account_invoice.py | 13 ++++++------- .../tests/test_account_invoice_tax_required.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/account_invoice_tax_required/README.rst b/account_invoice_tax_required/README.rst index 4e1aaa948..8fd6a3bb4 100644 --- a/account_invoice_tax_required/README.rst +++ b/account_invoice_tax_required/README.rst @@ -22,7 +22,7 @@ To use this module, you need to: .. 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 + :target: https://runbot.odoo-community.org/runbot/92/10.0 Bug Tracker @@ -41,6 +41,7 @@ Contributors * Vincent Renaville * Angel Moya +* Kitti U. Maintainer ---------- diff --git a/account_invoice_tax_required/__manifest__.py b/account_invoice_tax_required/__manifest__.py index f006e5040..ef0df1f99 100644 --- a/account_invoice_tax_required/__manifest__.py +++ b/account_invoice_tax_required/__manifest__.py @@ -4,7 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': "Tax required in invoice", - 'version': "9.0.1.0.0", + 'version': "10.0.1.0.0", "author": "Camptocamp,Tecnativa,Odoo Community Association (OCA)", 'website': "http://www.camptocamp.com", 'category': "Localisation / Accounting", diff --git a/account_invoice_tax_required/models/account_invoice.py b/account_invoice_tax_required/models/account_invoice.py index b1cc8ba55..e3101fb3c 100644 --- a/account_invoice_tax_required/models/account_invoice.py +++ b/account_invoice_tax_required/models/account_invoice.py @@ -3,15 +3,16 @@ # Copyright 2016 - Tecnativa - Angel Moya # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, api, exceptions, _ -from openerp.tools import config +from odoo import models, api, _ +from odoo.exceptions import UserError +from odoo.tools import config class AccountInvoice(models.Model): _inherit = "account.invoice" @api.multi - def test_invoice_line_tax(self): + def _test_invoice_line_tax(self): errors = [] error_template = _("Invoice has a line with product %s with no taxes") for invoice_line in self.mapped('invoice_line_ids'): @@ -19,17 +20,15 @@ class AccountInvoice(models.Model): error_string = error_template % (invoice_line.name) errors.append(error_string) if errors: - raise exceptions.Warning( + raise UserError( _('%s\n%s') % (_('No Taxes Defined!'), '\n'.join(x for x in errors)) ) - else: - return True @api.multi def invoice_validate(self): if not (config['test_enable'] and not self.env.context.get('test_tax_required')): - self.test_invoice_line_tax() + self._test_invoice_line_tax() res = super(AccountInvoice, self).invoice_validate() return res diff --git a/account_invoice_tax_required/tests/test_account_invoice_tax_required.py b/account_invoice_tax_required/tests/test_account_invoice_tax_required.py index 7c4eb848d..2c4d5f7ed 100644 --- a/account_invoice_tax_required/tests/test_account_invoice_tax_required.py +++ b/account_invoice_tax_required/tests/test_account_invoice_tax_required.py @@ -2,8 +2,8 @@ # Copyright 2016 - Tecnativa - Angel Moya # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp.tests.common import TransactionCase -from openerp import exceptions +from odoo.tests.common import TransactionCase +from odoo import exceptions class TestAccountInvoiceTaxRequired(TransactionCase):