[FIX] account_asset_management: Analytic Account Migration Script

This commit is contained in:
Eduardo De Miguel
2024-09-23 11:20:38 +02:00
parent 95d96c671b
commit f8fb2b353b
5 changed files with 70 additions and 9 deletions

View File

@@ -153,6 +153,10 @@ Contributors
* Manuel Regidor <manuel.regidor@sygel.es>
* `Moduon <https://www.moduon.team>`_:
* Eduardo de Miguel
Maintainers
~~~~~~~~~~~

View File

@@ -0,0 +1,51 @@
# Copyright 2024 Moduon Team S.L. <info@moduon.team>
# 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
""",
)

View File

@@ -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:

View File

@@ -24,3 +24,7 @@
* `Sygel <https://www.sygel.es>`_:
* Manuel Regidor <manuel.regidor@sygel.es>
* `Moduon <https://www.moduon.team>`_:
* Eduardo de Miguel

View File

@@ -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
<li>Manuel Regidor &lt;<a class="reference external" href="mailto:manuel.regidor&#64;sygel.es">manuel.regidor&#64;sygel.es</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.moduon.team">Moduon</a>:<ul>
<li>Eduardo de Miguel</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-13">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>