mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
* Remove incorrect oldname attributes. * Add filter on partners for running contracts (+ a support o2m field for that). * Cover more tables in model renaming + cleaner code using a loop. * Don't copy contract lines, but rename table + copy contract records on pre. * Contract code is now populated to "Reference/Description" field in invoice. * Order on new contract model has been restored to the same as old analytic accounts.
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
# Copyright 2019 ACSONE SA/NV
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
|
|
import logging
|
|
|
|
from openupgradelib import openupgrade
|
|
from odoo.tools import parse_version
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _update_no_update_ir_cron(env):
|
|
# Update ir.cron
|
|
env.ref('contract.contract_cron_for_invoice').model_id = env.ref(
|
|
'contract.model_contract_contract'
|
|
)
|
|
env.ref('contract.contract_line_cron_for_renew').model_id = env.ref(
|
|
'contract.model_contract_line'
|
|
)
|
|
env.ref('contract.email_contract_template').model_id = env.ref(
|
|
'contract.model_contract_contract'
|
|
)
|
|
|
|
|
|
def _init_last_date_invoiced_on_contract_lines(env):
|
|
_logger.info("init last_date_invoiced field for contract lines")
|
|
contract_lines = env["contract.line"].search(
|
|
[("recurring_next_date", "!=", False)]
|
|
)
|
|
contract_lines._init_last_date_invoiced()
|
|
|
|
|
|
def _init_invoicing_partner_id_on_contracts(env):
|
|
_logger.info("Populate invoicing partner field on contracts")
|
|
contracts = env["contract.contract"].search([])
|
|
contracts._inverse_partner_id()
|
|
|
|
|
|
@openupgrade.migrate()
|
|
def migrate(env, version):
|
|
_update_no_update_ir_cron(env)
|
|
if parse_version(version) < parse_version('12.0.2.0.0'):
|
|
# We check the version here as this post-migration script was in
|
|
# 12.0.2.0.0 and already done for those who used the module when
|
|
# it was a PR
|
|
_init_last_date_invoiced_on_contract_lines(env)
|
|
_init_invoicing_partner_id_on_contracts(env)
|