Skip to content

Commit

Permalink
[MIG] account_journal_restrict_mode: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SaraDForgeFlow committed Dec 16, 2024
1 parent ab8f370 commit 5aec5e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 34 deletions.
2 changes: 1 addition & 1 deletion account_journal_restrict_mode/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Account Journal Restrict Mode",
"summary": "Lock All Posted Entries of Journals.",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-tools",
"category": "Accounting",
Expand Down
12 changes: 2 additions & 10 deletions account_journal_restrict_mode/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ def _check_journal_restrict_mode(self):
for rec in self:
if not rec.restrict_mode_hash_table:
raise UserError(
_("Journal %s must have Lock Posted Entries enabled.") % rec.name
self.env._("Journal %s must have Lock Posted Entries enabled.") % rec.name
)

@api.model_create_multi
def create(self, vals_list):
# Proposed fix to odoo https://github.com/odoo/odoo/pull/147738.
# But while they don't merge (as it's not an issue they will face in Odoo standard...)
journals = super().create(vals_list)
for journal in journals:
if journal.restrict_mode_hash_table and not journal.secure_sequence_id:
journal._create_secure_sequence(["secure_sequence_id"])
return journals

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
@tagged("post_install", "-at_install")
class TestAccountJournalRestrictMode(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
def setUpClass(cls):
super().setUpClass()
cls.account_journal_obj = cls.env["account.journal"]
cls.company_obj = cls.env["res.company"]
cls.currency_obj = cls.env["res.currency"]
Expand All @@ -26,24 +26,3 @@ def test_journal_default_lock_entries(self):
with self.assertRaises(UserError):
journal.write({"restrict_mode_hash_table": False})

def test_journal_default_secure_sequence_new_company(self):
test_company = self.company_obj.create(
{
"name": "My Test Company",
"currency_id": self.currency_obj.search([("name", "=", "USD")]).id,
"country_id": self.country_be.id,
}
)
self.chart_template_obj.try_loading(
template_code="generic_coa", company=test_company, install_demo=False
)
journals = self.env["account.journal"].search(
[("company_id", "=", test_company.id)]
)
self.assertTrue(journals)
self.assertTrue(
all(
journal.restrict_mode_hash_table and journal.secure_sequence_id
for journal in journals
)
)

0 comments on commit 5aec5e2

Please sign in to comment.