From b9d88dd98801b9d0e247ae37b2f491388bd659bb Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 12 Mar 2019 12:35:24 +0100 Subject: [PATCH] [FIX] account_invoice_tax_required: Avoid gaps in sequence Using `invoice_validate` method for validating invoice, makes the call to the sequence to be done before, and although rollbacking the transaction, the next number is already assigned and then you may have gaps in your numbering. Thus, we do the check before this, on the first executed method. --- account_invoice_tax_required/__manifest__.py | 2 +- account_invoice_tax_required/models/account_invoice.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/account_invoice_tax_required/__manifest__.py b/account_invoice_tax_required/__manifest__.py index f13104816..1be008f55 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': "10.0.1.0.1", + 'version': "10.0.1.0.2", "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 37886588f..d2ad67d34 100644 --- a/account_invoice_tax_required/models/account_invoice.py +++ b/account_invoice_tax_required/models/account_invoice.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2015 - Camptocamp SA - Author Vincent Renaville # Copyright 2016 - Tecnativa - Angel Moya +# Copyright 2019 - Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models, api, _ @@ -26,7 +27,7 @@ class AccountInvoice(models.Model): ) @api.multi - def invoice_validate(self): + def action_invoice_open(self): # Always test if it is required by context force_test = self.env.context.get('test_tax_required') skip_test = any(( @@ -40,4 +41,4 @@ class AccountInvoice(models.Model): )) if force_test or not skip_test: self._test_invoice_line_tax() - return super(AccountInvoice, self).invoice_validate() + return super(AccountInvoice, self).action_invoice_open()