diff --git a/account_lock_to_date/README.rst b/account_lock_to_date/README.rst index 66d54bbdc..06e79f4bf 100644 --- a/account_lock_to_date/README.rst +++ b/account_lock_to_date/README.rst @@ -14,13 +14,13 @@ Account Lock To Date :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/12.0/account_lock_to_date + :target: https://github.com/OCA/account-financial-tools/tree/13.0/account_lock_to_date :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-12-0/account-financial-tools-12-0-account_lock_to_date + :target: https://translation.odoo-community.org/projects/account-financial-tools-13-0/account-financial-tools-13-0-account_lock_to_date :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/92/12.0 + :target: https://runbot.odoo-community.org/runbot/92/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -51,7 +51,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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -82,6 +82,6 @@ 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. -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_lock_to_date/__manifest__.py b/account_lock_to_date/__manifest__.py index 3cbc24256..b33ef4476 100644 --- a/account_lock_to_date/__manifest__.py +++ b/account_lock_to_date/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Lock To Date", "summary": """ Allows to set an account lock date in the future.""", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "license": "AGPL-3", "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-financial-tools", diff --git a/account_lock_to_date/i18n/account_lock_to_date.pot b/account_lock_to_date/i18n/account_lock_to_date.pot index 8177fda56..f7896a9ce 100644 --- a/account_lock_to_date/i18n/account_lock_to_date.pot +++ b/account_lock_to_date/i18n/account_lock_to_date.pot @@ -1,30 +1,25 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_lock_to_date +# * account_lock_to_date # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: account_lock_to_date -#: model:ir.model,name:account_lock_to_date.model_account_move -msgid "Account Entry" -msgstr "" - #. module: account_lock_to_date #: model:ir.model,name:account_lock_to_date.model_account_update_lock_to_date msgid "Account Update Lock_to_date" msgstr "" #. module: account_lock_to_date -#: model:ir.ui.view,arch_db:account_lock_to_date.account_update_lock_to_date_form_view +#: model_terms:ir.ui.view,arch_db:account_lock_to_date.account_update_lock_to_date_form_view msgid "Cancel" msgstr "" @@ -34,97 +29,115 @@ msgid "Companies" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_company_id +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__company_id msgid "Company" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_create_uid +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__create_uid msgid "Created by" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_create_date +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__create_date msgid "Created on" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_display_name +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__display_name msgid "Display Name" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_id +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__id msgid "ID" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date___last_update +#: model:ir.model,name:account_lock_to_date.model_account_move +msgid "Journal Entries" +msgstr "" + +#. module: account_lock_to_date +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date____last_update msgid "Last Modified on" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_write_uid +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__write_uid msgid "Last Updated by" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_write_date +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__write_date msgid "Last Updated on" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_fiscalyear_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_res_company_fiscalyear_lock_to_date +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__fiscalyear_lock_to_date +#: model:ir.model.fields,field_description:account_lock_to_date.field_res_company__fiscalyear_lock_to_date msgid "Lock To Date" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date_period_lock_to_date -#: model:ir.model.fields,field_description:account_lock_to_date.field_res_company_period_lock_to_date +#: model:ir.model.fields,field_description:account_lock_to_date.field_account_update_lock_to_date__period_lock_to_date +#: model:ir.model.fields,field_description:account_lock_to_date.field_res_company__period_lock_to_date msgid "Lock To Date for Non-Advisers" msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,help:account_lock_to_date.field_account_update_lock_to_date_fiscalyear_lock_to_date -msgid "No users, including Advisers, can edit accounts after and inclusive of this date. Use it for fiscal year locking for example." +#: model:ir.model.fields,help:account_lock_to_date.field_account_update_lock_to_date__fiscalyear_lock_to_date +msgid "" +"No users, including Advisers, can edit accounts after and inclusive of this " +"date. Use it for fiscal year locking for example." msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,help:account_lock_to_date.field_res_company_fiscalyear_lock_to_date -msgid "No users, including Advisers, can edit accounts after this date. Use it for fiscal year locking for example." +#: model:ir.model.fields,help:account_lock_to_date.field_res_company__fiscalyear_lock_to_date +msgid "" +"No users, including Advisers, can edit accounts after this date. Use it for " +"fiscal year locking for example." msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,help:account_lock_to_date.field_account_update_lock_to_date_period_lock_to_date -msgid "Only users with the 'Adviser' role can edit accounts after and inclusive of this date. Use it for period locking inside an open fiscal year, for example." +#: model:ir.model.fields,help:account_lock_to_date.field_account_update_lock_to_date__period_lock_to_date +msgid "" +"Only users with the 'Adviser' role can edit accounts after and inclusive of " +"this date. Use it for period locking inside an open fiscal year, for " +"example." msgstr "" #. module: account_lock_to_date -#: model:ir.model.fields,help:account_lock_to_date.field_res_company_period_lock_to_date -msgid "Only users with the 'Adviser' role can edit accounts after this date. Use it for period locking inside an open fiscal year, for example." +#: model:ir.model.fields,help:account_lock_to_date.field_res_company__period_lock_to_date +msgid "" +"Only users with the 'Adviser' role can edit accounts after this date. Use it" +" for period locking inside an open fiscal year, for example." msgstr "" #. module: account_lock_to_date -#: code:addons/account_lock_to_date/models/res_company.py:63 +#: code:addons/account_lock_to_date/models/res_company.py:0 #, python-format msgid "The lock date for advisors is irreversible and can't be removed." msgstr "" #. module: account_lock_to_date -#: code:addons/account_lock_to_date/models/res_company.py:71 +#: code:addons/account_lock_to_date/models/res_company.py:0 #, python-format -msgid "The new lock to date for advisors must be set after the previous lock to date." +msgid "" +"The new lock to date for advisors must be set after the previous lock to " +"date." msgstr "" #. module: account_lock_to_date -#: code:addons/account_lock_to_date/models/res_company.py:117 +#: code:addons/account_lock_to_date/models/res_company.py:0 #, python-format -msgid "There are still unposted entries in the period to date you want to lock. You should either post or delete them." +msgid "" +"There are still unposted entries in the period to date you want to lock. You" +" should either post or delete them." msgstr "" #. module: account_lock_to_date -#: model:ir.ui.view,arch_db:account_lock_to_date.account_update_lock_to_date_form_view +#: model_terms:ir.ui.view,arch_db:account_lock_to_date.account_update_lock_to_date_form_view msgid "Update" msgstr "" @@ -135,32 +148,38 @@ msgid "Update accounting lock to dates" msgstr "" #. module: account_lock_to_date -#: code:addons/account_lock_to_date/wizards/account_update_lock_to_date.py:43 +#: code:addons/account_lock_to_date/wizards/account_update_lock_to_date.py:0 #, python-format msgid "You are not allowed to execute this action." msgstr "" #. module: account_lock_to_date -#: code:addons/account_lock_to_date/models/account_move.py:21 +#: code:addons/account_lock_to_date/models/account_move.py:0 #, python-format -msgid "You cannot add/modify entries after and inclusive of the lock to date %s" +msgid "" +"You cannot add/modify entries after and inclusive of the lock to date %s" msgstr "" #. module: account_lock_to_date -#: code:addons/account_lock_to_date/models/account_move.py:25 +#: code:addons/account_lock_to_date/models/account_move.py:0 #, python-format -msgid "You cannot add/modify entries after and inclusive of the lock to date %s. Check the company settings or ask someone with the 'Adviser' role" +msgid "" +"You cannot add/modify entries after and inclusive of the lock to date %s. " +"Check the company settings or ask someone with the 'Adviser' role" msgstr "" #. module: account_lock_to_date -#: code:addons/account_lock_to_date/models/res_company.py:103 +#: code:addons/account_lock_to_date/models/res_company.py:0 #, python-format -msgid "You cannot define stricter conditions on advisors than on users. Please make sure that the lock date on advisor is set after the lock date for users." +msgid "" +"You cannot define stricter conditions on advisors than on users. Please make" +" sure that the lock date on advisor is set after the lock date for users." msgstr "" #. module: account_lock_to_date -#: code:addons/account_lock_to_date/models/res_company.py:85 +#: code:addons/account_lock_to_date/models/res_company.py:0 #, python-format -msgid "You cannot lock a period that is not finished yet. Please make sure that the lock date for advisors is not set after the last day of the previous month." +msgid "" +"You cannot lock a period that is not finished yet. Please make sure that the" +" lock date for advisors is not set after the last day of the previous month." msgstr "" - diff --git a/account_lock_to_date/models/account_move.py b/account_lock_to_date/models/account_move.py index a6a841dde..574ef9db8 100644 --- a/account_lock_to_date/models/account_move.py +++ b/account_lock_to_date/models/account_move.py @@ -1,15 +1,13 @@ # Copyright 2019 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, api, models +from odoo import _, models from odoo.exceptions import UserError class AccountMove(models.Model): _inherit = "account.move" - @api.multi - def _check_lock_date(self): - res = super()._check_lock_date() + def _check_lock_to_dates(self): for move in self: lock_to_date = ( min( @@ -34,4 +32,15 @@ class AccountMove(models.Model): "with the 'Adviser' role" ) % (lock_to_date) raise UserError(message) - return res + + def action_post(self): + self._check_lock_to_dates() + return super().action_post() + + def button_cancel(self): + self._check_lock_to_dates() + return super().button_cancel() + + def button_draft(self): + self._check_lock_to_dates() + return super().button_draft() diff --git a/account_lock_to_date/models/res_company.py b/account_lock_to_date/models/res_company.py index 177955062..0c9f1b14b 100644 --- a/account_lock_to_date/models/res_company.py +++ b/account_lock_to_date/models/res_company.py @@ -7,7 +7,7 @@ from time import mktime from dateutil.relativedelta import relativedelta -from odoo import SUPERUSER_ID, _, api, fields, models +from odoo import SUPERUSER_ID, _, fields, models from odoo.exceptions import ValidationError from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT @@ -28,14 +28,12 @@ class ResCompany(models.Model): "this date. Use it for fiscal year locking for example.", ) - @api.multi def write(self, vals): # fiscalyear_lock_date can't be set to a prior date if "fiscalyear_lock_to_date" in vals or "period_lock_to_date" in vals: self._check_lock_to_dates(vals) return super(ResCompany, self).write(vals) - @api.multi def _check_lock_to_dates(self, vals): """Check the lock to dates for the current companies. @@ -118,7 +116,6 @@ class ResCompany(models.Model): ) ) - @api.multi def _validate_fiscalyear_lock(self, values): res = super()._validate_fiscalyear_lock(values) if values.get("fiscalyear_lock_to_date"): diff --git a/account_lock_to_date/static/description/index.html b/account_lock_to_date/static/description/index.html index 3d14db922..0a700e198 100644 --- a/account_lock_to_date/static/description/index.html +++ b/account_lock_to_date/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runbot

This module allows to set a Period and Fiscal year Locking end dates. This will prevent users from posting journal entries on a date after the defined period or fiscal year end date.

@@ -397,7 +397,7 @@ journal entries on the date “Lock To Date” or after.

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

+feedback.

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

@@ -425,7 +425,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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.

-

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_lock_to_date/tests/test_account_lock_to_date_update.py b/account_lock_to_date/tests/test_account_lock_to_date_update.py index c419ff593..9bbddfe3e 100644 --- a/account_lock_to_date/tests/test_account_lock_to_date_update.py +++ b/account_lock_to_date/tests/test_account_lock_to_date_update.py @@ -14,9 +14,9 @@ class TestAccountLockToDateUpdate(TransactionCase): self.company = self.env.ref("base.main_company") self.demo_user = self.env.ref("base.user_demo") self.adviser_group = self.env.ref("account.group_account_manager") - self.UpdateLockToDateUpdateObj = self.env["account.update.lock_to_date"].sudo( - self.demo_user - ) + self.UpdateLockToDateUpdateObj = self.env[ + "account.update.lock_to_date" + ].with_user(self.demo_user) self.AccountObj = self.env["account.account"] self.AccountJournalObj = self.env["account.journal"] self.AccountMoveObj = self.env["account.move"] @@ -89,7 +89,7 @@ class TestAccountLockToDateUpdate(TransactionCase): ) self.demo_user.write({"groups_id": [(3, self.adviser_group.id)]}) with self.assertRaises(UserError): - wizard.sudo(self.demo_user.id).execute() + wizard.with_user(self.demo_user.id).execute() def test_02_update_with_access(self): wizard = self.create_account_lock_date_update() @@ -100,7 +100,7 @@ class TestAccountLockToDateUpdate(TransactionCase): } ) self.demo_user.write({"groups_id": [(4, self.adviser_group.id)]}) - wizard.sudo(self.demo_user.id).execute() + wizard.with_user(self.demo_user.id).execute() self.assertEqual( self.company.period_lock_to_date, datetime.strptime("2900-01-01", DEFAULT_SERVER_DATE_FORMAT).date(), @@ -117,7 +117,7 @@ class TestAccountLockToDateUpdate(TransactionCase): self.company.fiscalyear_lock_to_date = "2900-02-01" move = self.create_account_move("2900-01-01") with self.assertRaises(UserError): - move.sudo(self.demo_user.id).post() + move.with_user(self.demo_user.id).action_post() def test_04_create_move_inside_period(self): """We test that we can successfully create a journal entry @@ -125,7 +125,7 @@ class TestAccountLockToDateUpdate(TransactionCase): self.company.period_lock_to_date = "2900-01-01" self.company.fiscalyear_lock_to_date = "2900-02-01" move = self.create_account_move("2800-01-01") - move.sudo(self.demo_user.id).post() + move.with_user(self.demo_user.id).action_post() self.assertEqual(move.state, "posted") def test_05_lock_period_with_draft_moves(self): diff --git a/account_lock_to_date/wizards/account_update_lock_to_date.py b/account_lock_to_date/wizards/account_update_lock_to_date.py index 254072d4d..4e0cb063d 100644 --- a/account_lock_to_date/wizards/account_update_lock_to_date.py +++ b/account_lock_to_date/wizards/account_update_lock_to_date.py @@ -41,14 +41,12 @@ class AccountUpdateLockToDate(models.TransientModel): ) return res - @api.multi def _check_execute_allowed(self): self.ensure_one() has_adviser_group = self.env.user.has_group("account.group_account_manager") if not (has_adviser_group or self.env.uid == SUPERUSER_ID): raise UserError(_("You are not allowed to execute this action.")) - @api.multi def execute(self): self.ensure_one() self._check_execute_allowed() diff --git a/account_lock_to_date/wizards/account_update_lock_to_date.xml b/account_lock_to_date/wizards/account_update_lock_to_date.xml index 5af8e85a7..2d1e8086e 100644 --- a/account_lock_to_date/wizards/account_update_lock_to_date.xml +++ b/account_lock_to_date/wizards/account_update_lock_to_date.xml @@ -1,44 +1,50 @@ - + - account.update.lock_to_date.form account.update.lock_to_date
-
+
- - - + + +
-
- - Update accounting lock to dates account.update.lock_to_date form new - Update accounting lock to dates - - - - + + + + -