mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] account_asset_management: Analytic Account Migration Script
This commit is contained in:
@@ -153,6 +153,10 @@ Contributors
|
|||||||
|
|
||||||
* Manuel Regidor <manuel.regidor@sygel.es>
|
* Manuel Regidor <manuel.regidor@sygel.es>
|
||||||
|
|
||||||
|
* `Moduon <https://www.moduon.team>`_:
|
||||||
|
|
||||||
|
* Eduardo de Miguel
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
""",
|
||||||
|
)
|
||||||
@@ -382,11 +382,6 @@ class AccountAsset(models.Model):
|
|||||||
else:
|
else:
|
||||||
asset.prorata = asset.profile_id.prorata
|
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")
|
@api.depends("profile_id")
|
||||||
def _compute_analytic_distribution(self):
|
def _compute_analytic_distribution(self):
|
||||||
for asset in self:
|
for asset in self:
|
||||||
|
|||||||
@@ -24,3 +24,7 @@
|
|||||||
* `Sygel <https://www.sygel.es>`_:
|
* `Sygel <https://www.sygel.es>`_:
|
||||||
|
|
||||||
* Manuel Regidor <manuel.regidor@sygel.es>
|
* Manuel Regidor <manuel.regidor@sygel.es>
|
||||||
|
|
||||||
|
* `Moduon <https://www.moduon.team>`_:
|
||||||
|
|
||||||
|
* Eduardo de Miguel
|
||||||
|
|||||||
@@ -8,10 +8,11 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
:Author: David Goodger (goodger@python.org)
|
: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.
|
:Copyright: This stylesheet has been placed in the public domain.
|
||||||
|
|
||||||
Default cascading style sheet for the HTML output of Docutils.
|
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
|
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||||
customize this style sheet.
|
customize this style sheet.
|
||||||
@@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
|||||||
margin-left: 2em ;
|
margin-left: 2em ;
|
||||||
margin-right: 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, code { background-color: #eeeeee }
|
||||||
pre.code .comment, code .comment { color: #5C6576 }
|
pre.code .comment, code .comment { color: #5C6576 }
|
||||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||||
@@ -300,7 +301,7 @@ span.option {
|
|||||||
span.pre {
|
span.pre {
|
||||||
white-space: pre }
|
white-space: pre }
|
||||||
|
|
||||||
span.problematic {
|
span.problematic, pre.problematic {
|
||||||
color: red }
|
color: red }
|
||||||
|
|
||||||
span.section-subtitle {
|
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 <<a class="reference external" href="mailto:manuel.regidor@sygel.es">manuel.regidor@sygel.es</a>></li>
|
<li>Manuel Regidor <<a class="reference external" href="mailto:manuel.regidor@sygel.es">manuel.regidor@sygel.es</a>></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li><a class="reference external" href="https://www.moduon.team">Moduon</a>:<ul>
|
||||||
|
<li>Eduardo de Miguel</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-13">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-13">Maintainers</a></h2>
|
||||||
<p>This module is maintained by the OCA.</p>
|
<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
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user