diff --git a/contract/README.rst b/contract/README.rst index fc4cadbd90..01a37ea558 100644 --- a/contract/README.rst +++ b/contract/README.rst @@ -7,7 +7,7 @@ Recurring - Contracts Management !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:19d8f78874c9775e7c788c7eed046d74ff47c6b86acb42ce1e80aeb905eed3c7 + !! source digest: sha256:08650aaf9f41e3d6c539cc52fdb02a84ad85f7bf3cdb4f63ebbd561f443bdd04 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 3166520b7d..2da7ec4579 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -11,7 +11,7 @@ { "name": "Recurring - Contracts Management", - "version": "16.0.1.1.3", + "version": "16.0.2.0.0", "category": "Contract Management", "license": "AGPL-3", "author": "Tecnativa, ACSONE SA/NV, Odoo Community Association (OCA)", diff --git a/contract/migrations/16.0.2.0.0/pre-migrate.py b/contract/migrations/16.0.2.0.0/pre-migrate.py new file mode 100644 index 0000000000..bb310b8aef --- /dev/null +++ b/contract/migrations/16.0.2.0.0/pre-migrate.py @@ -0,0 +1,33 @@ +# © 2023 initOS GmbH +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import json +import logging + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + """Migrate analytic account from contract line to analytic distribution""" + + _logger.info("Migrating analytic distribution for contract.line") + cr.execute( + """ + SELECT id, analytic_account_id, analytic_distribution + FROM contract_line + WHERE analytic_account_id IS NOT NULL + """ + ) + for line_id, analytic_account_id, analytic_distribution in cr.fetchall(): + analytic_account_id = str(analytic_account_id) + if analytic_distribution: + analytic_distribution[analytic_account_id] = ( + analytic_distribution.get(analytic_account_id, 0) + 100 + ) + else: + analytic_distribution = {analytic_account_id: 100} + + cr.execute( + "UPDATE contract_line SET analytic_distribution = %s WHERE id = %s", + (json.dumps(analytic_distribution), line_id), + ) diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py index 6e3e1cae2f..aa3c6f7440 100644 --- a/contract/models/contract_line.py +++ b/contract/models/contract_line.py @@ -33,10 +33,6 @@ class ContractLine(models.Model): ondelete="cascade", ) currency_id = fields.Many2one(related="contract_id.currency_id") - analytic_account_id = fields.Many2one( - string="Analytic account", - comodel_name="account.analytic.account", - ) date_start = fields.Date(required=True) date_end = fields.Date(compute="_compute_date_end", store=True, readonly=False) termination_notice_date = fields.Date( diff --git a/contract/static/description/index.html b/contract/static/description/index.html index adb072f1e4..cac18f3660 100644 --- a/contract/static/description/index.html +++ b/contract/static/description/index.html @@ -366,7 +366,7 @@

Recurring - Contracts Management

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:19d8f78874c9775e7c788c7eed046d74ff47c6b86acb42ce1e80aeb905eed3c7 +!! source digest: sha256:08650aaf9f41e3d6c539cc52fdb02a84ad85f7bf3cdb4f63ebbd561f443bdd04 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Production/Stable License: AGPL-3 OCA/contract Translate me on Weblate Try me on Runboat

This module enables contracts management with recurring diff --git a/contract/views/contract.xml b/contract/views/contract.xml index 0c64822367..a32b0f923c 100644 --- a/contract/views/contract.xml +++ b/contract/views/contract.xml @@ -217,7 +217,8 @@ /> @@ -316,7 +317,8 @@ diff --git a/contract/views/contract_line.xml b/contract/views/contract_line.xml index 7ac002e39e..d8223f04ce 100644 --- a/contract/views/contract_line.xml +++ b/contract/views/contract_line.xml @@ -47,10 +47,6 @@ groups="analytic.group_analytic_accounting" attrs="{'invisible': [('display_type', '!=', False)]}" > - -