From f8fb2b353b592737e97ea3e22ef2d4ede5c66e91 Mon Sep 17 00:00:00 2001 From: Eduardo De Miguel Date: Mon, 23 Sep 2024 11:20:38 +0200 Subject: [PATCH] [FIX] account_asset_management: Analytic Account Migration Script --- account_asset_management/README.rst | 4 ++ .../migrations/16.0.1.0.0/pre-migration.py | 51 +++++++++++++++++++ .../models/account_asset.py | 5 -- .../readme/CONTRIBUTORS.rst | 4 ++ .../static/description/index.html | 15 ++++-- 5 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 account_asset_management/migrations/16.0.1.0.0/pre-migration.py diff --git a/account_asset_management/README.rst b/account_asset_management/README.rst index 16c139b8c..2de74610a 100644 --- a/account_asset_management/README.rst +++ b/account_asset_management/README.rst @@ -153,6 +153,10 @@ Contributors * Manuel Regidor +* `Moduon `_: + + * Eduardo de Miguel + Maintainers ~~~~~~~~~~~ diff --git a/account_asset_management/migrations/16.0.1.0.0/pre-migration.py b/account_asset_management/migrations/16.0.1.0.0/pre-migration.py new file mode 100644 index 000000000..e9c32e4a5 --- /dev/null +++ b/account_asset_management/migrations/16.0.1.0.0/pre-migration.py @@ -0,0 +1,51 @@ +# Copyright 2024 Moduon Team S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + """Migrate Analytic Accounts to Analytic Distributions on Assets and Profiles""" + openupgrade.add_fields( + env, + [ + ( + "analytic_distribution", + "account.asset", + "account_asset", + "json", + "jsonb", + "account_asset_management", + None, + ), + ( + "analytic_distribution", + "account.asset.profile", + "account_asset_profile", + "json", + "jsonb", + "account_asset_management", + None, + ), + ], + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE account_asset + SET analytic_distribution = jsonb_build_object( + account_analytic_id::text, 100.0 + ) + WHERE account_analytic_id IS NOT NULL + """, + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE account_asset_profile + SET analytic_distribution = jsonb_build_object( + account_analytic_id::text, 100.0 + ) + WHERE account_analytic_id IS NOT NULL + """, + ) diff --git a/account_asset_management/models/account_asset.py b/account_asset_management/models/account_asset.py index 1224535a1..5d446335a 100644 --- a/account_asset_management/models/account_asset.py +++ b/account_asset_management/models/account_asset.py @@ -382,11 +382,6 @@ class AccountAsset(models.Model): else: asset.prorata = asset.profile_id.prorata - @api.depends("profile_id") - def _compute_account_analytic_id(self): - for asset in self: - asset.account_analytic_id = asset.profile_id.account_analytic_id - @api.depends("profile_id") def _compute_analytic_distribution(self): for asset in self: diff --git a/account_asset_management/readme/CONTRIBUTORS.rst b/account_asset_management/readme/CONTRIBUTORS.rst index 5f2ab0135..a45dcbed1 100644 --- a/account_asset_management/readme/CONTRIBUTORS.rst +++ b/account_asset_management/readme/CONTRIBUTORS.rst @@ -24,3 +24,7 @@ * `Sygel `_: * Manuel Regidor + +* `Moduon `_: + + * Eduardo de Miguel diff --git a/account_asset_management/static/description/index.html b/account_asset_management/static/description/index.html index ee793a898..59b343dd8 100644 --- a/account_asset_management/static/description/index.html +++ b/account_asset_management/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.option { span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -511,12 +512,18 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Manuel Regidor <manuel.regidor@sygel.es>
  • +
  • Moduon:
      +
    • Eduardo de Miguel
    • +
    +
  • Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    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.