mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] contract: Remove analytic_account_id and add migration
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)",
|
||||
|
||||
33
contract/migrations/16.0.2.0.0/pre-migrate.py
Normal file
33
contract/migrations/16.0.2.0.0/pre-migrate.py
Normal file
@@ -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),
|
||||
)
|
||||
@@ -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(
|
||||
@@ -559,24 +555,12 @@ class ContractLine(models.Model):
|
||||
self.last_date_invoiced, self.recurring_next_date
|
||||
)
|
||||
name = self._insert_markers(dates[0], dates[1])
|
||||
|
||||
analytic_distribution = self.analytic_distribution
|
||||
analytic_account_id = self.analytic_account_id.id
|
||||
if analytic_account_id:
|
||||
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}
|
||||
|
||||
return {
|
||||
"quantity": self._get_quantity_to_invoice(*dates),
|
||||
"product_uom_id": self.uom_id.id,
|
||||
"discount": self.discount,
|
||||
"contract_line_id": self.id,
|
||||
"analytic_distribution": analytic_distribution,
|
||||
"analytic_distribution": self.analytic_distribution,
|
||||
"sequence": self.sequence,
|
||||
"name": name,
|
||||
"price_unit": self.price_unit,
|
||||
|
||||
@@ -366,7 +366,7 @@ ul.auto-toc {
|
||||
!! 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&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
|
||||
|
||||
@@ -216,11 +216,6 @@
|
||||
invisible="1"
|
||||
/>
|
||||
<field name="name" widget="section_and_note_text" />
|
||||
<field
|
||||
name="analytic_account_id"
|
||||
groups="analytic.group_analytic_accounting"
|
||||
optional="hide"
|
||||
/>
|
||||
<field
|
||||
name="analytic_distribution"
|
||||
widget="analytic_distribution"
|
||||
@@ -321,11 +316,6 @@
|
||||
<field name="sequence" widget="handle" />
|
||||
<field name="product_id" />
|
||||
<field name="name" widget="section_and_note_text" />
|
||||
<field
|
||||
name="analytic_account_id"
|
||||
groups="analytic.group_analytic_accounting"
|
||||
optional="hide"
|
||||
/>
|
||||
<field
|
||||
name="analytic_distribution"
|
||||
widget="analytic_distribution"
|
||||
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user