[MIG] account_sequence_option: Migration to 15.0

This commit is contained in:
ps-tubtim
2023-04-24 00:01:23 +07:00
committed by Saran440
parent 46528cf71e
commit 051ad6e8ea
5 changed files with 37 additions and 21 deletions

View File

@@ -7,7 +7,7 @@ Account Sequence Option
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:df796ab170be63ac8b03450b6f8ca4740ce9c4b3dd20a72b19d8ae363b3d6669 !! source digest: sha256:9c050df168dabec54905eecdf02c85a15e2ab98ab86081822a234e3766d3416f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png .. |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 :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github .. |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 :alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |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 :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -70,7 +70,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_. 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. 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 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_sequence_option%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_sequence_option%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. Do not contact contributors directly about support or help with technical issues.
@@ -111,6 +111,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-kittiu| |maintainer-kittiu|
This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/14.0/account_sequence_option>`_ project on GitHub. This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/15.0/account_sequence_option>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -4,7 +4,7 @@
{ {
"name": "Account Sequence Option", "name": "Account Sequence Option",
"summary": "Manage sequence options for account.move, i.e., invoice, bill, entry", "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)", "author": "Ecosoft, Odoo Community Association (OCA)",
"development_status": "Alpha", "development_status": "Alpha",
"website": "https://github.com/OCA/account-financial-tools", "website": "https://github.com/OCA/account-financial-tools",

View File

@@ -8,16 +8,21 @@ class AccountMove(models.Model):
_inherit = "account.move" _inherit = "account.move"
sequence_option = fields.Boolean( sequence_option = fields.Boolean(
compute="_compute_name", compute="_compute_sequence_option",
default=False, default=False,
copy=False, copy=False,
store=True, store=True,
index=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") @api.depends("posted_before", "state", "journal_id", "date")
def _compute_name(self): def _compute_name(self):
#
options = self.env["ir.sequence.option.line"].get_model_options(self._name) options = self.env["ir.sequence.option.line"].get_model_options(self._name)
# On post, get the sequence option # On post, get the sequence option
if options: if options:
@@ -32,7 +37,7 @@ class AccountMove(models.Model):
rec.sequence_option = True rec.sequence_option = True
# Call super() # Call super()
super()._compute_name() res = super()._compute_name()
if options: if options:
for rec in self: for rec in self:
# On create new, odoo may suggest the 1st new number, remove it. # 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 and not rec.sequence_option
): ):
rec.name = "/" rec.name = "/"
return res
# Bypass constrains if sequence is defined # Bypass constrains if sequence is defined
def _constrains_date_sequence(self): def _constrains_date_sequence(self):

View File

@@ -367,9 +367,9 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:df796ab170be63ac8b03450b6f8ca4740ce9c4b3dd20a72b19d8ae363b3d6669 !! source digest: sha256:9c050df168dabec54905eecdf02c85a15e2ab98ab86081822a234e3766d3416f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/14.0/account_sequence_option"><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-14-0/account-financial-tools-14-0-account_sequence_option"><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=14.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="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-financial-tools/tree/15.0/account_sequence_option"><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-15-0/account-financial-tools-15-0-account_sequence_option"><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=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module extends module base_sequence_option and allow you to <p>This module extends module base_sequence_option and allow you to
provide optional sequences for account.move documents, i.e., invoice, bill, journal entry.</p> provide optional sequences for account.move documents, i.e., invoice, bill, journal entry.</p>
<p>To use this module, enable developer mode, and check “Use sequence options” <p>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.
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-tools/issues">GitHub Issues</a>. <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. 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 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_sequence_option%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_sequence_option%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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -445,7 +445,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/kittiu"><img alt="kittiu" src="https://github.com/kittiu.png?size=40px" /></a></p> <p><a class="reference external image-reference" href="https://github.com/kittiu"><img alt="kittiu" src="https://github.com/kittiu.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_sequence_option">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_sequence_option">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> <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>
</div> </div>

View File

@@ -36,7 +36,7 @@ class TestAccountSequenceOption(TransactionCase):
"default_partner_type": partner_type, "default_partner_type": partner_type,
"default_move_journal_types": ("bank", "cash"), "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.payment_type = payment_type
move_form.partner_type = partner_type move_form.partner_type = partner_type
move_form.partner_id = self.partner_id move_form.partner_id = self.partner_id
@@ -53,27 +53,34 @@ class TestAccountSequenceOption(TransactionCase):
# 1. Customer Invoice # 1. Customer Invoice
self.invoice = self._create_invoice("out_invoice") self.invoice = self._create_invoice("out_invoice")
self.invoice.action_post() 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 # 2. Vendor Bill
self.invoice = self._create_invoice("in_invoice") self.invoice = self._create_invoice("in_invoice")
self.invoice.action_post() 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 # 3. Customer Refund
self.invoice = self._create_invoice("out_refund") self.invoice = self._create_invoice("out_refund")
self.invoice.action_post() 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 # 4. Vendor Refund
self.invoice = self._create_invoice("in_refund") self.invoice = self._create_invoice("in_refund")
self.invoice.action_post() 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 # 5. Customer Payment
self.payment = self._create_payment("inbound", "customer") self.payment = self._create_payment("inbound", "customer")
self.payment.action_post() 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 # 6. Vendor Payment
self.payment = self._create_payment("outbound", "supplier") self.payment = self._create_payment("outbound", "supplier")
self.payment.action_post() 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 # 7. Create out invoice, post invoice, reset invoice to Draft
# Change Date, post invoice. # Change Date, post invoice.
self.invoice = self._create_invoice("out_invoice") self.invoice = self._create_invoice("out_invoice")
@@ -85,3 +92,6 @@ class TestAccountSequenceOption(TransactionCase):
) )
self.invoice.action_post() self.invoice.action_post()
self.assertEqual(old_name, self.invoice.name) self.assertEqual(old_name, self.invoice.name)
def test_constrains_date_sequence_true(self):
self.assertTrue(self.env["account.move"]._constrains_date_sequence())