Skip to content

Commit

Permalink
[18.0][MIG] account_move_name_sequence: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BertVGroenendael committed Oct 21, 2024
1 parent adfdf38 commit 598e640
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 39 deletions.
14 changes: 9 additions & 5 deletions account_move_name_sequence/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,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/17.0/account_move_name_sequence
:target: https://github.com/OCA/account-financial-tools/tree/18.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-17-0/account-financial-tools-17-0-account_move_name_sequence
:target: https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-0-account_move_name_sequence
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -98,7 +98,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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20account_move_name_sequence%0Aversion:%2017.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:%2018.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.

Expand Down Expand Up @@ -127,6 +127,10 @@ Contributors

- Rodrigo Bonilla Martinez <[email protected]>

- `Dynapps <https://www.dynapps.eu>`__:

- Bert Van Groenendael <[email protected]>

Maintainers
-----------

Expand Down Expand Up @@ -154,6 +158,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-alexis-via| |maintainer-moylop260| |maintainer-luisg123v|

This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/17.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/18.0/account_move_name_sequence>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_move_name_sequence/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{
"name": "Account Move Number Sequence",
"version": "17.0.1.0.5",
"version": "18.0.1.0.0",
"category": "Accounting",
"license": "AGPL-3",
"summary": "Generate journal entry number from sequence",
Expand Down
14 changes: 10 additions & 4 deletions account_move_name_sequence/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class AccountJournal(models.Model):
copy=False,
check_company=True,
domain="[('company_id', '=', company_id)]",
help="This sequence will be used to generate the journal entry number for refunds.",
help="This sequence will be used to generate "
"the journal entry number for refunds.",
)
# Redefine the default to True as <=v13.0
refund_sequence = fields.Boolean(default=True)
Expand Down Expand Up @@ -188,10 +189,15 @@ def _prepare_sequence_current_moves(self, refund=False):
if prefix3
else "''"
)
select_max_number = f"MAX(split_part(name, '{prefixes[-1]}', {prefixes.count(prefixes[-1]) + 1})::INTEGER) AS max_number"
select_max_number = (
f"MAX(split_part(name, '{prefixes[-1]}', "
f"{prefixes.count(prefixes[-1]) + 1}):"
f":INTEGER) AS max_number"
)
query = (
f"SELECT {select_year}, {select_month}, {select_max_number} FROM account_move "
"WHERE name LIKE %s AND journal_id=%s GROUP BY 1,2"
f"SELECT {select_year}, {select_month}, "
f"{select_max_number} FROM account_move "
f"WHERE name LIKE %s AND journal_id=%s GROUP BY 1,2"
)

# It is not using user input
Expand Down
2 changes: 2 additions & 0 deletions account_move_name_sequence/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
- Francisco Luna \<<[email protected]>\>
- [Factor Libre](https://www.factorlibre.com):
- Rodrigo Bonilla Martinez \<<[email protected]>\>
- [Dynapps](https://www.dynapps.eu):
- Bert Van Groenendael \<<[email protected]>\>
21 changes: 14 additions & 7 deletions account_move_name_sequence/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +369,7 @@ <h1 class="title">Account Move Number Sequence</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:03b876b8607b5c34b0f49870637439187af2b3913e3af50d384838d28ef870ee
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/account-financial-tools/tree/17.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 image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-17-0/account-financial-tools-17-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/account-financial-tools/tree/18.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 image-reference" href="https://translation.odoo-community.org/projects/account-financial-tools-18-0/account-financial-tools-18-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-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
Expand Down Expand Up @@ -438,7 +439,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<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 to smash 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:%2017.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:%2018.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">
Expand Down Expand Up @@ -466,18 +467,24 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<li>Rodrigo Bonilla Martinez &lt;<a class="reference external" href="mailto:rodrigo.bonilla&#64;factorlibre.com">rodrigo.bonilla&#64;factorlibre.com</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.dynapps.eu">Dynapps</a>:<ul>
<li>Bert Van Groenendael &lt;<a class="reference external" href="mailto:bert.vangroenendael&#64;dynapps.eu">bert.vangroenendael&#64;dynapps.eu</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
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 image-reference" href="https://github.com/alexis-via"><img alt="alexis-via" src="https://github.com/alexis-via.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/moylop260"><img alt="moylop260" src="https://github.com/moylop260.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/luisg123v"><img alt="luisg123v" src="https://github.com/luisg123v.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/17.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/18.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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class TestAccountIncomingSupplierInvoice(AccountTestInvoicingCommon):
"""Testing creating account move fetching mail.alias"""

@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
def setUpClass(cls):
super().setUpClass()

cls.env["ir.config_parameter"].sudo().set_param(
"mail.catchall.domain", "test-company.odoo.com"
Expand Down Expand Up @@ -59,14 +59,25 @@ def test_supplier_invoice_mailed_from_supplier(self):
message_parsed = {
"message_id": "message-id-dead-beef",
"subject": "Incoming bill",
"from": f"{self.supplier_partner.name} <{self.supplier_partner.email}>",
"to": f"{self.journal.alias_id.alias_name}@{self.journal.alias_id.alias_domain}",
"from": f"{self.supplier_partner.name} " f"<{self.supplier_partner.email}>",
"to": f"{self.journal.alias_id.alias_name}@"
f"{self.journal.alias_id.alias_domain}",
"body": "You know, that thing that you bought.",
"attachments": [b"Hello, invoice"],
}

invoice = self.env["account.move"].message_new(
message_parsed, {"move_type": "in_invoice", "journal_id": self.journal.id}
invoice = (
self.env["account.move"]
.with_context(
tracking_disable=False,
mail_create_nolog=False,
mail_create_nosubscribe=False,
mail_notrack=False,
)
.message_new(
message_parsed,
{"move_type": "in_invoice", "journal_id": self.journal.id},
)
)

message_ids = invoice.message_ids
Expand Down
18 changes: 13 additions & 5 deletions account_move_name_sequence/tests/test_account_move_name_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

from odoo import fields
from odoo.exceptions import UserError, ValidationError
from odoo.tests import tagged
from odoo.tests.common import Form, TransactionCase
from odoo.tests import Form, tagged
from odoo.tests.common import TransactionCase


@tagged("post_install", "-at_install")
Expand Down Expand Up @@ -59,7 +59,7 @@ def setUp(self):
}
)
self.accounts = self.env["account.account"].search(
[("company_id", "=", self.company.id)], limit=2
[("company_ids", "=", self.company.id)], limit=2
)
self.account1 = self.accounts[0]
self.account2 = self.accounts[1]
Expand Down Expand Up @@ -275,7 +275,11 @@ def test_remove_invoice_error_secuence_no_grap(self):
)
self.assertEqual(invoice.name, "/")
invoice.action_post()
error_msg = "You can't delete a posted journal item. Don’t play games with your accounting records; reset the journal entry to draft before deleting it."
error_msg = (
"You can't delete a posted journal item. "
"Don’t play games with your accounting records; "
"reset the journal entry to draft before deleting it."
)
with self.assertRaisesRegex(UserError, error_msg):
invoice.unlink()
invoice.button_draft()
Expand Down Expand Up @@ -307,7 +311,11 @@ def test_remove_invoice_error_secuence_standard(self):
)
self.assertEqual(in_refund_invoice.name, "/")
in_refund_invoice.action_post()
error_msg = "You can't delete a posted journal item. Don’t play games with your accounting records; reset the journal entry to draft before deleting it."
error_msg = (
"You can't delete a posted journal item. "
"Don’t play games with your accounting records; "
"reset the journal entry to draft before deleting it."
)
with self.assertRaisesRegex(UserError, error_msg):
in_refund_invoice.unlink()
in_refund_invoice.button_draft()
Expand Down
Loading

0 comments on commit 598e640

Please sign in to comment.