From 0dc729c88698e8871f7a6f16a58e6c3139b38fdd Mon Sep 17 00:00:00 2001 From: Francisco Javier Luna Vazquez Date: Wed, 25 May 2022 17:58:09 -0500 Subject: [PATCH] [FIX] account_move_name_sequence: Exclude no_gap sequences from _is_end_of_seq_chain --- account_move_name_sequence/README.rst | 10 +++--- .../i18n/account_move_name_sequence.pot | 31 ++++--------------- .../models/account_move.py | 9 ++++++ .../static/description/index.html | 6 ++-- .../tests/test_account_move_name_seq.py | 25 +++++++++++++++ 5 files changed, 48 insertions(+), 33 deletions(-) diff --git a/account_move_name_sequence/README.rst b/account_move_name_sequence/README.rst index 8811eb96f..0d9fe0a78 100644 --- a/account_move_name_sequence/README.rst +++ b/account_move_name_sequence/README.rst @@ -14,13 +14,13 @@ Account Move Number Sequence :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github - :target: https://github.com/OCA/account-financial-tools/tree/14.0/account_move_name_sequence + :target: https://github.com/OCA/account-financial-tools/tree/15.0/account_move_name_sequence :alt: OCA/account-financial-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_move_name_sequence + :target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_move_name_sequence :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/92/14.0 + :target: https://runbot.odoo-community.org/runbot/92/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -108,7 +108,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -155,6 +155,6 @@ Current `maintainers `__: |maintainer-alexis-via| |maintainer-moylop260| |maintainer-frahikLV| -This module is part of the `OCA/account-financial-tools `_ project on GitHub. +This module is part of the `OCA/account-financial-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_move_name_sequence/i18n/account_move_name_sequence.pot b/account_move_name_sequence/i18n/account_move_name_sequence.pot index 395f8e187..b9aa2fba1 100644 --- a/account_move_name_sequence/i18n/account_move_name_sequence.pot +++ b/account_move_name_sequence/i18n/account_move_name_sequence.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 14.0\n" +"Project-Id-Version: Odoo Server 15.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -37,13 +37,6 @@ msgstr "" msgid "Dedicated Credit Note Sequence" msgstr "" -#. module: account_move_name_sequence -#: model:ir.model.fields,field_description:account_move_name_sequence.field_account_journal__display_name -#: model:ir.model.fields,field_description:account_move_name_sequence.field_account_move__display_name -#: model:ir.model.fields,field_description:account_move_name_sequence.field_ir_sequence__display_name -msgid "Display Name" -msgstr "" - #. module: account_move_name_sequence #: model:ir.model.fields,field_description:account_move_name_sequence.field_account_journal__sequence_id msgid "Entry Sequence" @@ -56,13 +49,6 @@ msgstr "" msgid "Highest Name" msgstr "" -#. module: account_move_name_sequence -#: model:ir.model.fields,field_description:account_move_name_sequence.field_account_journal__id -#: model:ir.model.fields,field_description:account_move_name_sequence.field_account_move__id -#: model:ir.model.fields,field_description:account_move_name_sequence.field_ir_sequence__id -msgid "ID" -msgstr "" - #. module: account_move_name_sequence #: model:ir.model,name:account_move_name_sequence.model_account_journal msgid "Journal" @@ -73,13 +59,6 @@ msgstr "" msgid "Journal Entry" msgstr "" -#. module: account_move_name_sequence -#: model:ir.model.fields,field_description:account_move_name_sequence.field_account_journal____last_update -#: model:ir.model.fields,field_description:account_move_name_sequence.field_account_move____last_update -#: model:ir.model.fields,field_description:account_move_name_sequence.field_ir_sequence____last_update -msgid "Last Modified on" -msgstr "" - #. module: account_move_name_sequence #: model:ir.model.fields,field_description:account_move_name_sequence.field_account_bank_statement_line__name #: model:ir.model.fields,field_description:account_move_name_sequence.field_account_move__name @@ -126,14 +105,16 @@ msgstr "" #: code:addons/account_move_name_sequence/models/account_journal.py:0 #, python-format msgid "" -"The company is not set on sequence '%s' configured as credit note sequence " -"of journal '%s'." +"The company is not set on sequence '%(sequence)s' configured as credit note " +"sequence of journal '%(journal)s'." msgstr "" #. module: account_move_name_sequence #: code:addons/account_move_name_sequence/models/account_journal.py:0 #, python-format -msgid "The company is not set on sequence '%s' configured on journal '%s'." +msgid "" +"The company is not set on sequence '%(sequence)s' configured on journal " +"'%(journal)s'." msgstr "" #. module: account_move_name_sequence diff --git a/account_move_name_sequence/models/account_move.py b/account_move_name_sequence/models/account_move.py index ff1dbc759..6f63aab66 100644 --- a/account_move_name_sequence/models/account_move.py +++ b/account_move_name_sequence/models/account_move.py @@ -52,3 +52,12 @@ class AccountMove(models.Model): # We must by-pass this constraint of sequence.mixin def _constrains_date_sequence(self): return True + + def _is_end_of_seq_chain(self): + invoices_no_gap_sequences = self.filtered( + lambda inv: inv.journal_id.sequence_id.implementation == "no_gap" + ) + invoices_other_sequences = self - invoices_no_gap_sequences + if not invoices_other_sequences and invoices_no_gap_sequences: + return False + return super(AccountMove, invoices_other_sequences)._is_end_of_seq_chain() diff --git a/account_move_name_sequence/static/description/index.html b/account_move_name_sequence/static/description/index.html index 14a7905a9..e02281983 100644 --- a/account_move_name_sequence/static/description/index.html +++ b/account_move_name_sequence/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

In Odoo version 13.0 and previous versions, the number of journal entries was generated from a sequence configured on the journal.

In Odoo version 14.0, the number of journal entries can be manually set by the user. Then, the number attributed for the next journal entries in the same journal is computed by a complex piece of code that guesses the format of the journal entry number from the number of the journal entry which was manually entered by the user. It has several drawbacks:

    @@ -448,7 +448,7 @@ And even if you must use no-gap in your company or country it will reduce the co

    Bugs are tracked on GitHub 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.

    +feedback.

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

    @@ -477,7 +477,7 @@ mission is to support the collaborative development of Odoo features and promote its widespread use.

    Current maintainers:

    alexis-via moylop260 frahikLV

    -

    This module is part of the OCA/account-financial-tools project on GitHub.

    +

    This module is part of the OCA/account-financial-tools project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/account_move_name_sequence/tests/test_account_move_name_seq.py b/account_move_name_sequence/tests/test_account_move_name_seq.py index c6acf33c4..039cfc87c 100644 --- a/account_move_name_sequence/tests/test_account_move_name_seq.py +++ b/account_move_name_sequence/tests/test_account_move_name_seq.py @@ -1,10 +1,13 @@ # Copyright 2021 Akretion France (http://www.akretion.com/) # @author: Alexis de Lattre +# @author: Moisés López +# @author: Francisco Luna # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from datetime import datetime from odoo import fields +from odoo.exceptions import UserError from odoo.tests import tagged from odoo.tests.common import TransactionCase @@ -111,3 +114,25 @@ class TestAccountMoveNameSequence(TransactionCase): in_refund_invoice.button_draft() in_refund_invoice.action_post() self.assertEqual(in_refund_invoice.name, move_name) + + def test_remove_invoice_error(self): + invoice = self.env["account.move"].create( + { + "date": self.date, + "journal_id": self.misc_journal.id, + "line_ids": [ + (0, 0, {"account_id": self.account1.id, "debit": 10}), + (0, 0, {"account_id": self.account2.id, "credit": 10}), + ], + } + ) + self.assertEqual(invoice.name, "/") + invoice.action_post() + error_msg = "You cannot delete an item linked to a posted entry." + with self.assertRaisesRegex(UserError, error_msg): + invoice.unlink() + invoice.button_draft() + invoice.button_cancel() + error_msg = "You cannot delete this entry, as it has already consumed a" + with self.assertRaisesRegex(UserError, error_msg): + invoice.unlink()