diff --git a/account_sequence_option/README.rst b/account_sequence_option/README.rst index 39f857cbd..984b52beb 100644 --- a/account_sequence_option/README.rst +++ b/account_sequence_option/README.rst @@ -7,7 +7,7 @@ Account Sequence Option !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:df796ab170be63ac8b03450b6f8ca4740ce9c4b3dd20a72b19d8ae363b3d6669 + !! source digest: sha256:9c050df168dabec54905eecdf02c85a15e2ab98ab86081822a234e3766d3416f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png @@ -17,13 +17,13 @@ Account Sequence Option :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-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_sequence_option + :target: https://github.com/OCA/account-financial-tools/tree/15.0/account_sequence_option :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_sequence_option + :target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-account_sequence_option :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=14.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=15.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -70,7 +70,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 to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -111,6 +111,6 @@ Current `maintainer `__: |maintainer-kittiu| -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_sequence_option/__manifest__.py b/account_sequence_option/__manifest__.py index d02df7e07..b6e119893 100644 --- a/account_sequence_option/__manifest__.py +++ b/account_sequence_option/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Account Sequence Option", "summary": "Manage sequence options for account.move, i.e., invoice, bill, entry", - "version": "14.0.1.0.2", + "version": "15.0.1.0.0", "author": "Ecosoft, Odoo Community Association (OCA)", "development_status": "Alpha", "website": "https://github.com/OCA/account-financial-tools", diff --git a/account_sequence_option/models/account_move.py b/account_sequence_option/models/account_move.py index 6d6d039ac..313ba2fb0 100644 --- a/account_sequence_option/models/account_move.py +++ b/account_sequence_option/models/account_move.py @@ -8,16 +8,21 @@ class AccountMove(models.Model): _inherit = "account.move" sequence_option = fields.Boolean( - compute="_compute_name", + compute="_compute_sequence_option", default=False, copy=False, store=True, index=True, ) + @api.depends("posted_before", "state", "journal_id", "date") + def _compute_sequence_option(self): + if hasattr(self.env["account.journal"], "sequence_id"): + return + return self._compute_name() + @api.depends("posted_before", "state", "journal_id", "date") def _compute_name(self): - # options = self.env["ir.sequence.option.line"].get_model_options(self._name) # On post, get the sequence option if options: @@ -32,7 +37,7 @@ class AccountMove(models.Model): rec.sequence_option = True # Call super() - super()._compute_name() + res = super()._compute_name() if options: for rec in self: # On create new, odoo may suggest the 1st new number, remove it. @@ -50,6 +55,7 @@ class AccountMove(models.Model): and not rec.sequence_option ): rec.name = "/" + return res # Bypass constrains if sequence is defined def _constrains_date_sequence(self): diff --git a/account_sequence_option/static/description/index.html b/account_sequence_option/static/description/index.html index 81ce20a7d..ea06ae5e5 100644 --- a/account_sequence_option/static/description/index.html +++ b/account_sequence_option/static/description/index.html @@ -367,9 +367,9 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:df796ab170be63ac8b03450b6f8ca4740ce9c4b3dd20a72b19d8ae363b3d6669 +!! source digest: sha256:9c050df168dabec54905eecdf02c85a15e2ab98ab86081822a234e3766d3416f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Alpha License: LGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runboat

+

Alpha License: LGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runboat

This module extends module base_sequence_option and allow you to provide optional sequences for account.move documents, i.e., invoice, bill, journal entry.

To use this module, enable developer mode, and check “Use sequence options” @@ -415,7 +415,7 @@ Only for development or testing purpose, do not use in production.

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 to smash it by providing a detailed and welcomed -feedback.

+feedback.

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

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

Current maintainer:

kittiu

-

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_sequence_option/tests/test_account_sequence_option.py b/account_sequence_option/tests/test_account_sequence_option.py index 1b94d70e4..fc5a373c5 100644 --- a/account_sequence_option/tests/test_account_sequence_option.py +++ b/account_sequence_option/tests/test_account_sequence_option.py @@ -36,7 +36,7 @@ class TestAccountSequenceOption(TransactionCase): "default_partner_type": partner_type, "default_move_journal_types": ("bank", "cash"), } - move_form = Form(self.env["account.payment"].with_context(ctx)) + move_form = Form(self.env["account.payment"].with_context(**ctx)) move_form.payment_type = payment_type move_form.partner_type = partner_type move_form.partner_id = self.partner_id @@ -53,27 +53,34 @@ class TestAccountSequenceOption(TransactionCase): # 1. Customer Invoice self.invoice = self._create_invoice("out_invoice") self.invoice.action_post() - self.assertIn("CINV", self.invoice.name) + self.invoice._compute_name() + name = hasattr(self.env["account.journal"], "sequence_id") and "INV" or "CINV" + self.assertIn(name, self.invoice.name) # 2. Vendor Bill self.invoice = self._create_invoice("in_invoice") self.invoice.action_post() - self.assertIn("VBIL", self.invoice.name) + name = hasattr(self.env["account.journal"], "sequence_id") and "BILL" or "VBIL" + self.assertIn(name, self.invoice.name) # 3. Customer Refund self.invoice = self._create_invoice("out_refund") self.invoice.action_post() - self.assertIn("CREF", self.invoice.name) + name = hasattr(self.env["account.journal"], "sequence_id") and "RINV" or "CREF" + self.assertIn(name, self.invoice.name) # 4. Vendor Refund self.invoice = self._create_invoice("in_refund") self.invoice.action_post() - self.assertIn("VREF", self.invoice.name) + name = hasattr(self.env["account.journal"], "sequence_id") and "RBILL" or "VREF" + self.assertIn(name, self.invoice.name) # 5. Customer Payment self.payment = self._create_payment("inbound", "customer") self.payment.action_post() - self.assertIn("CPAY", self.payment.name) + name = hasattr(self.env["account.journal"], "sequence_id") and "BNK1" or "CPAY" + self.assertIn(name, self.payment.name) # 6. Vendor Payment self.payment = self._create_payment("outbound", "supplier") self.payment.action_post() - self.assertIn("VPAY", self.payment.name) + name = hasattr(self.env["account.journal"], "sequence_id") and "BNK1" or "VPAY" + self.assertIn(name, self.payment.name) # 7. Create out invoice, post invoice, reset invoice to Draft # Change Date, post invoice. self.invoice = self._create_invoice("out_invoice") @@ -85,3 +92,6 @@ class TestAccountSequenceOption(TransactionCase): ) self.invoice.action_post() self.assertEqual(old_name, self.invoice.name) + + def test_constrains_date_sequence_true(self): + self.assertTrue(self.env["account.move"]._constrains_date_sequence())