Skip to content

Commit

Permalink
[18.0][MIG] account_move_tier_validation: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkhao committed Nov 12, 2024
1 parent 4f314a7 commit 62b36c7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
3 changes: 3 additions & 0 deletions account_move_tier_validation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ Contributors

- Odoo Perú <info@odooperu.pe>
- Tharathip Chaweewongphan <tharathipc@ecosoft.co.th>
- `360ERP <https://www.360erp.com>`__:

- Kevin Khao <kevinkhao@gmail.com>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion account_move_tier_validation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Account Move Tier Validation",
"summary": "Extends the functionality of Account Moves to "
"support a tier validation process.",
"version": "16.0.1.0.1",
"version": "18.0.1.0.0",
"category": "Accounts",
"website": "https://github.com/OCA/account-invoicing",
"author": "PESOL, Odoo Community Association (OCA)",
Expand Down
12 changes: 6 additions & 6 deletions account_move_tier_validation/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright <2020> PESOL <info@pesol.es>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)

from odoo import _, api, models
from odoo import api, models


class AccountMove(models.Model):
Expand All @@ -23,15 +23,15 @@ def _get_under_validation_exceptions(self):
return super()._get_under_validation_exceptions() + ["needed_terms_dirty"]

def _get_to_validate_message_name(self):
name = super(AccountMove, self)._get_to_validate_message_name()
name = super()._get_to_validate_message_name()
if self.move_type == "in_invoice":
name = _("Bill")
name = self.env._("Bill")
elif self.move_type == "in_refund":
name = _("Refund")
name = self.env._("Refund")
elif self.move_type == "out_invoice":
name = _("Invoice")
name = self.env._("Invoice")
elif self.move_type == "out_refund":
name = _("Credit Note")
name = self.env._("Credit Note")
return name

def action_post(self):
Expand Down
2 changes: 2 additions & 0 deletions account_move_tier_validation/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
- Odoo Perú \<<info@odooperu.pe>\>
- Tharathip Chaweewongphan \<<tharathipc@ecosoft.co.th>\>
- [360ERP](https://www.360erp.com):
- Kevin Khao <<kevinkhao@gmail.com>>
4 changes: 4 additions & 0 deletions account_move_tier_validation/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li>Odoo Perú &lt;<a class="reference external" href="mailto:info&#64;odooperu.pe">info&#64;odooperu.pe</a>&gt;</li>
<li>Tharathip Chaweewongphan &lt;<a class="reference external" href="mailto:tharathipc&#64;ecosoft.co.th">tharathipc&#64;ecosoft.co.th</a>&gt;</li>
<li><a class="reference external" href="https://www.360erp.com">360ERP</a>:<ul>
<li>Kevin Khao &lt;<a class="reference external" href="mailto:kevinkhao&#64;gmail.com">kevinkhao&#64;gmail.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
21 changes: 14 additions & 7 deletions account_move_tier_validation/tests/test_tier_validation.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Copyright 2018 ForgeFlow S.L.
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).

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

from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT


@tagged("post_install", "-at_install")
class TestAccountTierValidation(common.TransactionCase):
class TestAccountTierValidation(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT))

def test_01_tier_definition_models(self):
res = self.env["tier.definition"]._get_tier_validation_model_names()
self.assertIn("account.move", res)
Expand All @@ -20,10 +27,10 @@ def test_02_form(self):
"model_id": self.env["ir.model"]
.search([("model", "=", "account.move")])
.id,
"definition_domain": "[('move_type', '=', '%s')]" % _type,
"definition_domain": f"[('move_type', '=', '{_type}')]",
}
)
with common.Form(
with Form(
self.env["account.move"].with_context(default_move_type=_type)
) as form:
form.save()
Expand Down Expand Up @@ -76,7 +83,7 @@ def test_03_move_post(self):
invoice.invalidate_model()
invoice.validate_tier()
with self.assertRaisesRegex(
ValidationError, _("You are not allowed to write those fields")
ValidationError, self.env._("You are not allowed to write those fields")
):
invoice._post()
# Calls _post method by passing context skip_validation_check set to True
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
odoo-addon-base_tier_validation @ git+https://github.com/OCA/server-ux.git@refs/pull/966/head#subdirectory=base_tier_validation

0 comments on commit 62b36c7

Please sign in to comment.