mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP] - store last_date_invoiced on contract_line
Improve CRITERIA_ALLOWED_DICT [IMP] - code improvement [IMP] - Use last_date_invoiced to set marker in invoice description [IMP] - add migration script to init last_day_invoiced and some other improvement [FIX] - a contract line suspended should start a day after the suspension end
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import logging
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
"""Copy recurrence info from contract to contract lines."""
|
||||
"""Copy recurrence info from contract to contract lines and compute
|
||||
last_date_invoiced"""
|
||||
|
||||
cr.execute(
|
||||
"""UPDATE account_analytic_invoice_line AS contract_line
|
||||
@@ -17,3 +23,10 @@ def migrate(cr, version):
|
||||
FROM account_analytic_account AS contract
|
||||
WHERE contract.id=contract_line.contract_id"""
|
||||
)
|
||||
|
||||
_logger.info("order all contract line")
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
contract_lines = env["account.analytic.invoice.line"].search(
|
||||
[("recurring_next_date", "!=", False)]
|
||||
)
|
||||
contract_lines._init_last_date_invoiced()
|
||||
|
||||
24
contract/migrations/12.0.2.0.0/pre-migration.py
Normal file
24
contract/migrations/12.0.2.0.0/pre-migration.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Copyright 2018 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
"""
|
||||
set recurring_next_date to false for finished contract
|
||||
"""
|
||||
_logger.info("order all contract line")
|
||||
with api.Environment(cr, SUPERUSER_ID, {}) as env:
|
||||
contracts = env["account.analytic.account"].search([])
|
||||
finished_contract = contracts.filtered(
|
||||
lambda c: not c.create_invoice_visibility
|
||||
)
|
||||
cr.execute(
|
||||
"UPDATE account_analytic_account set recurring_next_date=null where id in (%)"
|
||||
% ','.join(finished_contract.ids)
|
||||
)
|
||||
Reference in New Issue
Block a user