Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] contract: Usage of analytic distribution #1019

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contract/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contract/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
33 changes: 33 additions & 0 deletions contract/migrations/16.0.2.0.0/pre-migrate.py
Original file line number Diff line number Diff line change
@@ -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),
)
4 changes: 0 additions & 4 deletions contract/models/contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion contract/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ <h1 class="title">Recurring - Contracts Management</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:19d8f78874c9775e7c788c7eed046d74ff47c6b86acb42ce1e80aeb905eed3c7
!! source digest: sha256:08650aaf9f41e3d6c539cc52fdb02a84ad85f7bf3cdb4f63ebbd561f443bdd04
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/contract/tree/16.0/contract"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-16-0/contract-16-0-contract"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/contract&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module enables contracts management with recurring
Expand Down
6 changes: 4 additions & 2 deletions contract/views/contract.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@
/>
<field name="name" widget="section_and_note_text" />
<field
name="analytic_account_id"
name="analytic_distribution"
widget="analytic_distribution"
groups="analytic.group_analytic_accounting"
/>
<field name="quantity" />
Expand Down Expand Up @@ -316,7 +317,8 @@
<field name="product_id" />
<field name="name" widget="section_and_note_text" />
<field
name="analytic_account_id"
name="analytic_distribution"
widget="analytic_distribution"
groups="analytic.group_analytic_accounting"
/>
<field name="quantity" />
Expand Down
8 changes: 0 additions & 8 deletions contract/views/contract_line.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
groups="analytic.group_analytic_accounting"
attrs="{'invisible': [('display_type', '!=', False)]}"
>
<field
name="analytic_account_id"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_distribution"
widget="analytic_distribution"
Expand Down Expand Up @@ -102,10 +98,6 @@
<field name="sequence" widget="handle" />
<field name="product_id" />
<field name="name" />
<field
name="analytic_account_id"
groups="analytic.group_analytic_accounting"
/>
<field
name="analytic_distribution"
widget="analytic_distribution"
Expand Down
Loading