Skip to content

Commit

Permalink
Merge pull request #74 from arthru/account
Browse files Browse the repository at this point in the history
[8.0] 'account' migration.
  • Loading branch information
legalsylvain committed Sep 24, 2014
2 parents b6967c5 + e9db83f commit c1b9ad1
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 2 deletions.
186 changes: 186 additions & 0 deletions addons/account/migrations/8.0.1.1/openupgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
---Fields in module 'account'---

account / account.bank.statement / message_last_post (datetime) : NEW
# Field initialized

account / account.bank.statement.line / amount_currency (float) : NEW
# Nothing to do : optional field in the case the bank statement is in another currency

account / account.bank.statement.line / analytic_account_id (many2one): DEL relation: account.analytic.account
# Kept as a legacy column

account / account.bank.statement.line / bank_account_id (many2one) : NEW relation: res.partner.bank
# TODO is there a way to initialize that field ?

account / account.bank.statement.line / currency_id (many2one) : NEW relation: res.currency
# Nothing to do : optional field in the case the bank statement is in another currency

account / account.bank.statement.line / journal_entry_id (many2one) : NEW relation: account.move
account / account.bank.statement.line / move_ids (many2many) : DEL relation: account.move
# initialized journal_entry_id from move_ids

account / account.bank.statement.line / type (selection) : DEL required: required, selection_keys: ['customer', 'general', 'supplier'], req_default: general
# Kept as a legacy column

account / account.chart.template / currency_id (many2one) : NEW relation: res.currency
# currency_id is initialized in each xml defining an account.chart.template

account / account.invoice / message_last_post (datetime) : NEW
# Field initialized

account / account.invoice.report / country_id (many2one) : NEW relation: res.country
account / account.invoice.report / day (char) : DEL
account / account.invoice.report / month (selection) : DEL selection_keys: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
account / account.invoice.report / year (char) : DEL
# Nothing to do : account.invoice.report is a view

account / account.statement.operation.template / account_id (many2one) : NEW relation: account.account
account / account.statement.operation.template / amount (float) : NEW
account / account.statement.operation.template / amount_type (selection) : NEW required: required, selection_keys: ['fixed', 'percentage_of_balance', 'percentage_of_total'], req_default: fixed
account / account.statement.operation.template / analytic_account_id (many2one): NEW relation: account.analytic.account
account / account.statement.operation.template / label (char) : NEW
account / account.statement.operation.template / name (char) : NEW required: required
account / account.statement.operation.template / tax_id (many2one) : NEW relation: account.tax
# Nothing to do : new model

account / analytic.entries.report / day (char) : DEL
account / analytic.entries.report / month (selection) : DEL selection_keys: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
account / analytic.entries.report / year (char) : DEL
# Nothing to do : analytic.entries.report is a view

account / res.partner / invoice_ids (one2many) : relation is now 'account.invoice' ('account.invoice.line')
# Nothing to do for this field : partner_id on invoice_line is related from invoi

---XML records in module 'account'---
NEW account.analytic.journal: account.exp
## This was a demo data that became a data ; update in pre-migration

NEW ir.actions.act_window: account.action_account_moves_all_tree
NEW ir.actions.act_window: account.action_account_statement_operation_template
NEW ir.actions.act_window: account.action_open_partner_analytic_accounts
NEW ir.actions.act_window: account.action_view_account_statement_from_invoice_lines
DEL ir.actions.act_window: account.act_account_partner_account_move
DEL ir.actions.act_window: account.act_account_partner_account_move_all
DEL ir.actions.act_window: account.act_res_partner_2_account_invoice_opened
DEL ir.actions.act_window: account.action_analytic_open
DEL ir.actions.act_window: account.action_company_analysis_tree
DEL ir.actions.act_window: account.open_board_account
NEW ir.actions.client: account.action_bank_reconcile
NEW ir.actions.client: account.action_bank_reconcile_bank_statements
NEW ir.actions.report.xml: account.action_account_3rdparty_account_balance
NEW ir.actions.report.xml: account.action_account_analytic_account_inverted_balance
NEW ir.actions.report.xml: account.action_report_account_journal
NEW ir.actions.report.xml: account.action_report_account_salepurchasejournal
NEW ir.actions.report.xml: account.action_report_aged_partner_balance
NEW ir.actions.report.xml: account.action_report_analytic_balance
NEW ir.actions.report.xml: account.action_report_analytic_journal
NEW ir.actions.report.xml: account.action_report_central_journal
NEW ir.actions.report.xml: account.action_report_cost_ledger
NEW ir.actions.report.xml: account.action_report_cost_ledgerquantity
NEW ir.actions.report.xml: account.action_report_financial
NEW ir.actions.report.xml: account.action_report_general_journal
NEW ir.actions.report.xml: account.action_report_general_ledger
NEW ir.actions.report.xml: account.action_report_partner_ledger
NEW ir.actions.report.xml: account.action_report_partner_ledger_other
NEW ir.actions.report.xml: account.action_report_print_overdue
NEW ir.actions.report.xml: account.action_report_trial_balance
NEW ir.actions.report.xml: account.action_report_vat
DEL ir.actions.report.xml: account.account_3rdparty_account_balance
DEL ir.actions.report.xml: account.account_3rdparty_ledger
DEL ir.actions.report.xml: account.account_3rdparty_ledger_other
DEL ir.actions.report.xml: account.account_account_balance
DEL ir.actions.report.xml: account.account_analytic_account_balance
DEL ir.actions.report.xml: account.account_analytic_account_cost_ledger
DEL ir.actions.report.xml: account.account_analytic_account_inverted_balance
DEL ir.actions.report.xml: account.account_analytic_account_quantity_cost_ledger
DEL ir.actions.report.xml: account.account_central_journal
DEL ir.actions.report.xml: account.account_general_journal
DEL ir.actions.report.xml: account.account_general_ledger
DEL ir.actions.report.xml: account.account_general_ledger_landscape
DEL ir.actions.report.xml: account.account_journal
DEL ir.actions.report.xml: account.account_journal_sale_purchase
DEL ir.actions.report.xml: account.account_overdue
DEL ir.actions.report.xml: account.account_vat_declaration
DEL ir.actions.report.xml: account.analytic_journal_print
NEW ir.model.access: account.access_account_statement_operation_template
NEW ir.ui.menu: account.menu_action_account_statement_operation_template
NEW ir.ui.menu: account.menu_bank_reconcile_bank_statements
DEL ir.ui.menu: account.menu_board_account
NEW ir.ui.view: account.assets_backend
NEW ir.ui.view: account.partner_view_buttons
NEW ir.ui.view: account.product_template_search_view
NEW ir.ui.view: account.report_agedpartnerbalance
NEW ir.ui.view: account.report_analyticbalance
NEW ir.ui.view: account.report_analyticcostledger
NEW ir.ui.view: account.report_analyticcostledgerquantity
NEW ir.ui.view: account.report_analyticjournal
NEW ir.ui.view: account.report_centraljournal
NEW ir.ui.view: account.report_financial
NEW ir.ui.view: account.report_generaljournal
NEW ir.ui.view: account.report_generalledger
NEW ir.ui.view: account.report_invertedanalyticbalance
NEW ir.ui.view: account.report_invoice
NEW ir.ui.view: account.report_invoice_document
NEW ir.ui.view: account.report_journal
NEW ir.ui.view: account.report_overdue
NEW ir.ui.view: account.report_overdue_document
NEW ir.ui.view: account.report_partnerbalance
NEW ir.ui.view: account.report_partnerledger
NEW ir.ui.view: account.report_partnerledgerother
NEW ir.ui.view: account.report_salepurchasejournal
NEW ir.ui.view: account.report_trialbalance
NEW ir.ui.view: account.report_vat
NEW ir.ui.view: account.view_account_statement_from_invoice_lines
NEW ir.ui.view: account.view_account_statement_operation_template_form
NEW ir.ui.view: account.view_account_statement_operation_template_search
NEW ir.ui.view: account.view_account_statement_operation_template_tree
DEL ir.ui.view: account.board_account_form
DEL ir.ui.view: account.product_normal_form_view
DEL ir.ui.view: account.view_account_invoice_report_tree
DEL ir.ui.view: account.view_analytic_entries_report_tree
## Nothing to do : views

DEL process.node: account.process_node_accountingentries0
DEL process.node: account.process_node_accountingstatemententries0
DEL process.node: account.process_node_analytic0
DEL process.node: account.process_node_analyticcost0
DEL process.node: account.process_node_bankstatement0
DEL process.node: account.process_node_draftinvoices0
DEL process.node: account.process_node_draftstatement0
DEL process.node: account.process_node_electronicfile0
DEL process.node: account.process_node_importinvoice0
DEL process.node: account.process_node_invoiceinvoice0
DEL process.node: account.process_node_manually0
DEL process.node: account.process_node_paidinvoice0
DEL process.node: account.process_node_paymententries0
DEL process.node: account.process_node_reconciliation0
DEL process.node: account.process_node_supplieraccountingentries0
DEL process.node: account.process_node_supplierbankstatement0
DEL process.node: account.process_node_supplierdraftinvoices0
DEL process.node: account.process_node_supplierinvoiceinvoice0
DEL process.node: account.process_node_supplierpaidinvoice0
DEL process.node: account.process_node_supplierpaymentorder0
DEL process.node: account.process_node_supplierreconciliation0
DEL process.process: account.process_process_invoiceprocess0
DEL process.process: account.process_process_statementprocess0
DEL process.process: account.process_process_supplierinvoiceprocess0
DEL process.transition: account.process_transition_analyticinvoice0
DEL process.transition: account.process_transition_confirmstatementfromdraft0
DEL process.transition: account.process_transition_customerinvoice0
DEL process.transition: account.process_transition_entriesreconcile0
DEL process.transition: account.process_transition_filestatement0
DEL process.transition: account.process_transition_invoiceimport0
DEL process.transition: account.process_transition_invoicemanually0
DEL process.transition: account.process_transition_paymentorderbank0
DEL process.transition: account.process_transition_paymentorderreconcilation0
DEL process.transition: account.process_transition_paymentreconcile0
DEL process.transition: account.process_transition_reconcilepaid0
DEL process.transition: account.process_transition_statemententries0
DEL process.transition: account.process_transition_supplieranalyticcost0
DEL process.transition: account.process_transition_suppliercustomerinvoice0
DEL process.transition: account.process_transition_supplierentriesreconcile0
DEL process.transition: account.process_transition_supplierreconcilepaid0
DEL process.transition: account.process_transition_suppliervalidentries0
DEL process.transition: account.process_transition_validentries0
DEL process.transition.action: account.process_transition_action_createentries0
## Nothing to do : process has been deleted
55 changes: 55 additions & 0 deletions addons/account/migrations/8.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Akretion
# (<http://www.akretion.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from itertools import groupby

from openerp import pooler, SUPERUSER_ID
from openerp.openupgrade import openupgrade, openupgrade_80


def update_link_to_moves(cr):
cr.execute('''
SELECT statement_line_id, move_id
FROM bak_account_bank_statement_line_move_rel
ORDER BY statement_line_id;
''')
rows = cr.fetchall()
for k, v in groupby(rows, key=lambda r: r[0]):
v = list(v)
assert len(v) == 1
openupgrade.logged_query(
cr,
'''UPDATE account_bank_statement_line
SET journal_entry_id = %s
WHERE id = %s;''',
args=(v[0][1], v[0][0])
)


@openupgrade.migrate()
def migrate(cr, version):
pool = pooler.get_pool(cr.dbname)
uid = SUPERUSER_ID
openupgrade_80.set_message_last_post(
cr, uid, pool, ['account.bank.statement', 'account.invoice']
)
update_link_to_moves(cr)
51 changes: 51 additions & 0 deletions addons/account/migrations/8.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2014 Akretion (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp.openupgrade import openupgrade

column_renames = {
'account_bank_statement_line': [
('analytic_account_id', None),
('type', None),
]
}

tables_renames = [
(
'account_bank_statement_line_move_rel',
'bak_account_bank_statement_line_move_rel'
),
]


@openupgrade.migrate()
def migrate(cr, version):
if not version:
return

cr.execute(
"""SELECT id FROM account_analytic_journal WHERE type='purchase' """)
res = cr.fetchone()
if res:
openupgrade.add_xmlid(
cr, 'account', 'exp', 'account.analytic.journal', res[0], True)
openupgrade.rename_columns(cr, column_renames)
openupgrade.rename_tables(cr, tables_renames)
2 changes: 1 addition & 1 deletion openerp/openupgrade/doc/source/modules70-80.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Status :
+-----------------------------------+-----------------------------------+
|Module |Status |
+===================================+===================================+
|account | |
|account | Done |
+-----------------------------------+-----------------------------------+
|account_accountant | Nothing to do |
+-----------------------------------+-----------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion openerp/openupgrade/openupgrade_80.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ def set_message_last_post(cr, uid, pool, models):
cr, uid, [], context={'active_test': False})
last_posts = get_last_post_for_model(cr, uid, obj_ids, model_pool)
for i in obj_ids:
model_pool.write(cr, uid, i, {'message_last_post': last_posts[i]})
model_pool.write(cr, uid, [i], {'message_last_post': last_posts[i]})

0 comments on commit c1b9ad1

Please sign in to comment.