credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #05418
[Merge] lp:~sylvain-legal/openupgrade-addons/7.0-account_accountant into lp:openupgrade-addons
Sylvain LE GAL (GRAP) has proposed merging lp:~sylvain-legal/openupgrade-addons/7.0-account_accountant into lp:openupgrade-addons.
Requested reviews:
OpenUpgrade Committers (openupgrade-committers)
For more details, see:
https://code.launchpad.net/~sylvain-legal/openupgrade-addons/7.0-account_accountant/+merge/183851
[ADD] 'account_accoutant' analysis. (no change, so no code pushed).
--
https://code.launchpad.net/~sylvain-legal/openupgrade-addons/7.0-account_accountant/+merge/183851
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~sylvain-legal/openupgrade-addons/7.0-account_accountant into lp:openupgrade-addons.
=== modified file 'account/migrations/7.0.1.1/openupgrade_analysis_work.txt'
--- account/migrations/7.0.1.1/openupgrade_analysis_work.txt 2013-07-24 12:41:33 +0000
+++ account/migrations/7.0.1.1/openupgrade_analysis_work.txt 2013-09-04 11:22:13 +0000
@@ -1,22 +1,37 @@
---Fields in module 'account'---
-### TODO: migrate cashbox opening and closing items
+# 'opening_details_ids' replacing 'starting_details_ids' : one2many field based on account_cashbox_line.banck_statement_id (many2one) Nothing to do for the object account_banck_statement
+account / account.bank.statement / starting_details_ids (one2many): DEL relation: account.cashbox.line
+account / account.bank.statement / opening_details_ids (one2many): NEW relation: account.cashbox.line
+
+# 'closing_details_ids' replacing 'ending_details_ids' : one2many field based on account_cashbox_line.banck_statement_id (many2one) Nothing to do for the object account_banck_statement
+account / account.bank.statement / ending_details_ids (one2many) : DEL relation: account.cashbox.line
account / account.bank.statement / closing_details_ids (one2many): NEW relation: account.cashbox.line
+
+# new field one2many based on account_cashbox_line.banck_statement_id (many2one) Nothing to do for the object account_banck_statement
account / account.bank.statement / details_ids (one2many) : NEW relation: account.cashbox.line
-account / account.bank.statement / ending_details_ids (one2many) : DEL relation: account.cashbox.line
-account / account.bank.statement / opening_details_ids (one2many): NEW relation: account.cashbox.line
-account / account.bank.statement / starting_details_ids (one2many): DEL relation: account.cashbox.line
+
+### The account_cashbox_line concept changes a lot.
+# Use case : in the cashbox : at the opening state, there is 1 '1 euro coin' and at the closing state, 3 '1 euro coin'.
+# in 6.1 : there is 2 lines in account_cashbox_line. One with starting_id linked to the account_bank_statement (number=1), the other with the ending_id linked to the account_bank_statement (number=3)
+# in 7.0 : there is one line with number_opening = 1 and number_closing = 3
+# -> Migration script will delete all the "ending" and merge the data to the "starting" line. (If the starting line exists)
account / account.cashbox.line / bank_statement_id (many2one) : NEW relation: account.bank.statement
account / account.cashbox.line / ending_id (many2one) : DEL relation: account.bank.statement
+account / account.cashbox.line / starting_id (many2one) : DEL relation: account.bank.statement
account / account.cashbox.line / number (integer) : DEL
account / account.cashbox.line / number_closing (integer) : NEW
account / account.cashbox.line / number_opening (integer) : NEW
-account / account.cashbox.line / starting_id (many2one) : DEL relation: account.bank.statement
+
+### Ignore new fields
account / account.journal / cash_control (boolean) : NEW
+account / account.journal / with_last_closing_balance (boolean): NEW
account / account.journal / cashbox_line_ids (one2many) : NEW relation: account.journal.cashbox.line
-account / account.journal / with_last_closing_balance (boolean): NEW
+account / account.journal / internal_account_id (many2one): NEW relation: account.account
+
+### Ignore new fields (new table)
account / account.journal.cashbox.line / journal_id (many2one) : NEW relation: account.journal, required: required
account / account.journal.cashbox.line / pieces (float) : NEW
-account / account.journal / internal_account_id (many2one): NEW relation: account.account
+
### Ignore, no existing data to push as messages
account / account.bank.statement / message_ids (one2many) : NEW relation: mail.message
=== modified file 'account/migrations/7.0.1.1/post-migration.py'
--- account/migrations/7.0.1.1/post-migration.py 2013-07-24 12:41:33 +0000
+++ account/migrations/7.0.1.1/post-migration.py 2013-09-04 11:22:13 +0000
@@ -18,10 +18,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
+import logging
from openerp import pooler, SUPERUSER_ID
from openerp.openupgrade import openupgrade, openupgrade_70
+logger = logging.getLogger('OpenUpgrade')
+
def migrate_invoice_addresses(cr, pool):
# Contact id takes precedence over old partner id
openupgrade_70.set_partner_id_from_partner_address_id(
@@ -75,12 +77,101 @@
cr, SUPERUSER_ID, reconcile_ids,
{'opening_reconciliation': True})
+def merge_account_cashbox_line(cr, pool):
+ # Check an unmanaged case by the migration script
+ cr.execute("""
+ select count(*) as quantity2 from (
+ SELECT count(*) as quantity1
+ FROM account_cashbox_line
+ GROUP BY %s, %s, pieces) as tmp
+ WHERE quantity1 > 1
+ """%(
+ openupgrade.get_legacy_name('starting_id'),
+ openupgrade.get_legacy_name('ending_id'),
+ ))
+ count = cr.fetchone()[0]
+ if count>0:
+ logger.error('Some duplicated datas in account_cashbox_line (%s). This case is not covered.' %(count))
+
+ cashboxline_obj = pool.get('account.cashbox.line')
+ # Getting all the row from cashbox_line (type "ending")
+ cr.execute("""
+ SELECT id as id_end, pieces, %s as ending_id, %s as number
+ FROM account_cashbox_line
+ WHERE %s is not NULL AND bank_statement_id is NULL
+ """ %(
+ openupgrade.get_legacy_name('ending_id'),
+ openupgrade.get_legacy_name('number'),
+ openupgrade.get_legacy_name('ending_id'),
+ ))
+ for (id_end, pieces, ending_id, number) in cr.fetchall():
+ # Check if there is some corresping cashbox_line (type "starting")
+ cr.execute("""
+ SELECT id, %s
+ FROM account_cashbox_line
+ WHERE %s=%s AND pieces=%s
+ """ %(
+ openupgrade.get_legacy_name('number'),
+ openupgrade.get_legacy_name('starting_id'),
+ ending_id,
+ pieces,
+ ))
+
+ if cr.rowcount==0:
+ # "ending" cashbox_line becomes normal.
+ cashboxline_obj.write(
+ cr, SUPERUSER_ID, [id_end],
+ {
+ 'number_opening': 0,
+ 'number_closing': number,
+ 'bank_statement_id': ending_id,
+ })
+
+ elif cr.rowcount==1:
+ row = cr.fetchone()
+ # "starting" cashbox_line becomes normal with data of "ending" cashbox_line
+ cashboxline_obj.write(
+ cr, SUPERUSER_ID, [row[0]],
+ {
+ 'number_opening': row[1],
+ 'number_closing': number,
+ 'bank_statement_id': ending_id,
+ })
+ # delete the "ending" cashbox_line
+ cashboxline_obj.unlink(cr, SUPERUSER_ID, [id_end])
+
+ elif cr.rowcount>1:
+ # there is duplicated datas in the 6.1 Database
+ pass
+
+ # Getting all the row from cashbox_line (type "starting") they didn't change
+ cr.execute("""
+ SELECT id as id_start, %s as starting_id, %s as number
+ FROM account_cashbox_line
+ WHERE %s is not NULL AND bank_statement_id is NULL
+ """ %(
+ openupgrade.get_legacy_name('starting_id'),
+ openupgrade.get_legacy_name('number'),
+ openupgrade.get_legacy_name('starting_id'),
+ ))
+
+ for (id_start, starting_id, number) in cr.fetchall():
+ cashboxline_obj.write(
+ cr, SUPERUSER_ID, [id_start],
+ {
+ 'number_opening': number,
+ 'number_closing': 0,
+ 'bank_statement_id': starting_id,
+ })
+
+
@openupgrade.migrate()
def migrate(cr, version):
pool = pooler.get_pool(cr.dbname)
migrate_invoice_addresses(cr, pool)
migrate_invoice_names(cr, pool)
lock_closing_reconciliations(cr, pool)
+ merge_account_cashbox_line(cr, pool)
openupgrade.load_xml(
cr, 'account',
'migrations/7.0.1.1/data.xml')
=== modified file 'account/migrations/7.0.1.1/pre-migration.py'
--- account/migrations/7.0.1.1/pre-migration.py 2013-07-24 12:41:33 +0000
+++ account/migrations/7.0.1.1/pre-migration.py 2013-09-04 11:22:13 +0000
@@ -32,6 +32,12 @@
[
('name', None),
('note', None),
+ ],
+ 'account_cashbox_line':
+ [
+ ('ending_id', None),
+ ('starting_id', None),
+ ('number', None),
]
}
@@ -42,3 +48,4 @@
@openupgrade.migrate()
def migrate(cr, version):
openupgrade.rename_columns(cr, column_renames)
+ openupgrade.rename_xmlids(cr, xmlid_renames)
=== added file 'account_accountant/migrations/7.0.1.1/openupgrade_analysis_work.txt'
--- account_accountant/migrations/7.0.1.1/openupgrade_analysis_work.txt 1970-01-01 00:00:00 +0000
+++ account_accountant/migrations/7.0.1.1/openupgrade_analysis_work.txt 2013-09-04 11:22:13 +0000
@@ -0,0 +1,15 @@
+---Fields in module 'account_accountant'---
+---XML records in module 'account_accountant'---
+
+### New xml_ids. OK.
+NEW ir.actions.client: account_accountant.action_client_account_menu
+NEW mail.message: account_accountant.module_install_notification
+
+### xml_id from other module. (New). OK
+NEW ir.actions.todo: base.open_menu
+NEW ir.ui.menu: account.menu_account_config
+
+### xml_id from other module. (Existing). OK
+NEW ir.ui.menu: account.menu_finance
+
+
=== added file 'account_accountant/migrations/7.0.1.1/post-migration.py'
--- account_accountant/migrations/7.0.1.1/post-migration.py 1970-01-01 00:00:00 +0000
+++ account_accountant/migrations/7.0.1.1/post-migration.py 2013-09-04 11:22:13 +0000
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2013 Sylvain LE GAL
+#
+# 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
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ pass
=== added file 'account_accountant/migrations/7.0.1.1/pre-migration.py'
--- account_accountant/migrations/7.0.1.1/pre-migration.py 1970-01-01 00:00:00 +0000
+++ account_accountant/migrations/7.0.1.1/pre-migration.py 2013-09-04 11:22:13 +0000
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# This module copyright (C) 2013 Sylvain LE GAL
+#
+# 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
+
+@openupgrade.migrate()
+def migrate(cr, version):
+ pass
Follow ups