[FIX] account_move_name_sequence: Exclude no_gap sequences from _is_end_of_seq_chain

This commit is contained in:
Francisco Javier Luna Vazquez
2022-05-25 17:58:09 -05:00
committed by Marcos Oitaben
parent 522afcd487
commit 0dc729c886
5 changed files with 48 additions and 33 deletions

View File

@@ -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 <https://github.com/OCA/account-financial-tools/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 <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_name_sequence%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_name_sequence%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -155,6 +155,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-alexis-via| |maintainer-moylop260| |maintainer-frahikLV|
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/14.0/account_move_name_sequence>`_ project on GitHub.
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/15.0/account_move_name_sequence>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -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

View File

@@ -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()

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/14.0/account_move_name_sequence"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-14-0/account-financial-tools-14-0-account_move_name_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_move_name_sequence"><img alt="OCA/account-financial-tools" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_move_name_sequence"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/92/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>In Odoo version 13.0 and previous versions, the number of journal entries was generated from a sequence configured on the journal.</p>
<p>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:</p>
<ul class="simple">
@@ -448,7 +448,7 @@ And even if you must use no-gap in your company or country it will reduce the co
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_name_sequence%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_name_sequence%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -477,7 +477,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external" href="https://github.com/alexis-via"><img alt="alexis-via" src="https://github.com/alexis-via.png?size=40px" /></a> <a class="reference external" href="https://github.com/moylop260"><img alt="moylop260" src="https://github.com/moylop260.png?size=40px" /></a> <a class="reference external" href="https://github.com/frahikLV"><img alt="frahikLV" src="https://github.com/frahikLV.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/14.0/account_move_name_sequence">OCA/account-financial-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_move_name_sequence">OCA/account-financial-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -1,10 +1,13 @@
# Copyright 2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# @author: Moisés López <moylop260@vauxoo.com>
# @author: Francisco Luna <fluna@vauxoo.com>
# 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()