diff --git a/account_analytic_required/README.rst b/account_analytic_required/README.rst index e25e24e1ef..4c84127f20 100644 --- a/account_analytic_required/README.rst +++ b/account_analytic_required/README.rst @@ -29,7 +29,7 @@ Account Analytic Required |badge1| |badge2| |badge3| |badge4| |badge5| This module adds an option *analytic policy* on accounts. -You have the choice between 4 policies : *always*, *never*, *posted moves* and *optional*. +You have the choice between 4 policies : *always*, *never*, *posted moves* and empty (*optional*). **Table of contents** @@ -79,6 +79,7 @@ Contributors * `Trobz `_: * Nguyễn Minh Chiến +* Jairo Llopis (`Moduon `__) Other credits ~~~~~~~~~~~~~ diff --git a/account_analytic_required/__manifest__.py b/account_analytic_required/__manifest__.py index 84b8bc7777..ec480a9a23 100644 --- a/account_analytic_required/__manifest__.py +++ b/account_analytic_required/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) { "name": "Account Analytic Required", - "version": "16.0.1.0.1", + "version": "16.0.2.0.0", "category": "Analytic Accounting", "license": "AGPL-3", "author": "Akretion, Odoo Community Association (OCA)", diff --git a/account_analytic_required/migrations/16.0.2.0.0/post-migrate.py b/account_analytic_required/migrations/16.0.2.0.0/post-migrate.py new file mode 100644 index 0000000000..f708656e2e --- /dev/null +++ b/account_analytic_required/migrations/16.0.2.0.0/post-migrate.py @@ -0,0 +1,32 @@ +# Copyright 2024 Moduon Team S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) +"""Convert company-dependant field to normal.""" + + +def migrate(cr, version): + cr.execute( + r""" + UPDATE account_account AS acc + SET analytic_policy = prop.value_text + FROM ( + SELECT + substring(res_id FROM '\d+')::int AS account_id, + value_text + FROM ir_property + WHERE + name = 'analytic_policy' + AND res_id LIKE 'account.account,%' + AND value_text != 'optional' + ) AS prop + WHERE + acc.id = prop.account_id + """ + ) + cr.execute( + """ + DELETE FROM ir_property + WHERE + name = 'analytic_policy' + AND res_id LIKE 'account.account,%' + """ + ) diff --git a/account_analytic_required/models/account.py b/account_analytic_required/models/account.py index f06570eb42..fb1559d120 100644 --- a/account_analytic_required/models/account.py +++ b/account_analytic_required/models/account.py @@ -11,26 +11,22 @@ class AccountAccount(models.Model): analytic_policy = fields.Selection( selection=[ - ("optional", "Optional"), ("always", "Always"), ("posted", "Posted moves"), ("never", "Never"), ], string="Policy for analytic account", - default="optional", - company_dependent=True, help=( "Sets the policy for analytic accounts.\n" "If you select:\n" - "- Optional: The accountant is free to put an analytic account " + "- Empty: The accountant is free to put an analytic account " "on an account move line with this type of account.\n" "- Always: The accountant will get an error message if " "there is no analytic account.\n" "- Posted moves: The accountant will get an error message if no " "analytic account is defined when the move is posted.\n" "- Never: The accountant will get an error message if an analytic " - "account is present.\n\n" - "This field is company dependent." + "account is present." ), ) diff --git a/account_analytic_required/readme/CONTRIBUTORS.rst b/account_analytic_required/readme/CONTRIBUTORS.rst index 73c110add5..6e5972d8b7 100644 --- a/account_analytic_required/readme/CONTRIBUTORS.rst +++ b/account_analytic_required/readme/CONTRIBUTORS.rst @@ -10,3 +10,4 @@ * `Trobz `_: * Nguyễn Minh Chiến +* Jairo Llopis (`Moduon `__) diff --git a/account_analytic_required/readme/DESCRIPTION.rst b/account_analytic_required/readme/DESCRIPTION.rst index 2d54b80718..81760dbbe4 100644 --- a/account_analytic_required/readme/DESCRIPTION.rst +++ b/account_analytic_required/readme/DESCRIPTION.rst @@ -1,2 +1,2 @@ This module adds an option *analytic policy* on accounts. -You have the choice between 4 policies : *always*, *never*, *posted moves* and *optional*. +You have the choice between 4 policies : *always*, *never*, *posted moves* and empty (*optional*). diff --git a/account_analytic_required/static/description/index.html b/account_analytic_required/static/description/index.html index bbdfaa495a..2da18199b5 100644 --- a/account_analytic_required/static/description/index.html +++ b/account_analytic_required/static/description/index.html @@ -371,7 +371,7 @@

Account Analytic Required

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/account-analytic Translate me on Weblate Try me on Runboat

This module adds an option analytic policy on accounts. -You have the choice between 4 policies : always, never, posted moves and optional.

+You have the choice between 4 policies : always, never, posted moves and empty (optional).

Table of contents

+
  • Jairo Llopis (Moduon)

    +
  • diff --git a/account_analytic_required/tests/test_account_analytic_required.py b/account_analytic_required/tests/test_account_analytic_required.py index 06a6b82ccc..226acf0b3b 100644 --- a/account_analytic_required/tests/test_account_analytic_required.py +++ b/account_analytic_required/tests/test_account_analytic_required.py @@ -93,7 +93,7 @@ def _set_analytic_policy(self, policy, account=None): account.analytic_policy = policy def test_optional(self): - self._set_analytic_policy("optional") + self._set_analytic_policy(False) self._create_move(with_analytic=False) self._create_move(with_analytic=True)