Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---Fields in module 'analytic'---
analytic / account.analytic.account / account_type (selection) : DEL required: required, selection_keys: ['closed', 'normal'], req_default: normal
# TODO: pre-migraton: copy to new column
analytic / account.analytic.account / active (boolean) : NEW
# TODO: post-migraton: if account_type = closed, then set to False
#copied old account type field in pre and mapped to the new boolean in post
#(both closed = False and normal=True , this last map is a redundant because
#default is true)
---XML records in module 'analytic'---
NEW ir.actions.act_window: analytic.account_analytic_tag_action
DEL ir.actions.act_window: analytic.action_account_analytic_chart
Expand Down
18 changes: 18 additions & 0 deletions addons/analytic/migrations/10.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade

def deactivate_closed_accounts(cr):
# not using sql to restore account_type but map values
openupgrade.map_values(
cr, openupgrade.get_legacy_name('account_type'),
'active', [('closed' , False) , ('normal', True)],
table='account_analytic_account',
write='sql'
)

@openupgrade.migrate(use_env=True)
def migrate(env, version):
cr = env.cr
deactivate_closed_accounts(cr)
16 changes: 16 additions & 0 deletions addons/analytic/migrations/10.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade

@openupgrade.migrate(use_env=True)
def migrate(env, version):
cr = env.cr
# copy columns good practice in pre-mig script format of colum_spec should
# be: { Table_name_in_db : [( old_column_name , new_column_name, type)]
# defaults of new columname are fetchable via method get_legacy_name
openupgrade.copy_columns(cr, {
'account_analytic_account' : [
('account_type', None, None),
],
})
15 changes: 15 additions & 0 deletions addons/analytic/migrations/10.0.1.1/tests/analytic_data_v10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the test that checks that these accounts are inactive.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file contains data for automated testing the migration on travis
-

-
create some account_analytic_account that have type == 'closed', in casde the db does not have them in order to verify that the script works and that it will transform those in v10.0 bool ean field active = False
-
!record {model: account.analytic.account, id: analytic.ou_analytic_account_c1}:
name: 'OU Test closed'
type: 'closed'
-
!record {model: account.analytic.account, id: analytic.ou_analytic_account_n1}:
name: 'OU Test normal 2'
type: 'normal'
-
13 changes: 13 additions & 0 deletions addons/analytic/migrations/10.0.1.1/tests/test_analytic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# coding: utf-8
from openerp.tests.common import TransactionCase


class TestAnalytic(TransactionCase)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just discovered that this is not being executed, or this would be marked as error, as it misses the final :

cc @hbrunn @gfcapalbo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fixing the issues directly for getting a green build: https://travis-ci.org/OCA/OpenUpgrade/builds/232892182#L357

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially fixed on 993e0ec. Switching to PR for trying to fix the other error: https://travis-ci.org/OCA/OpenUpgrade/builds/232906089#L428


def test_analytic(self):
self.assertTrue(
self.env.ref('analytic.ou_analytic_account_c1').active == False
)
self.assertTrue(
self.env.ref('analytic.ou_analytic_account_n1').active == True
)
2 changes: 1 addition & 1 deletion odoo/openupgrade/doc/source/modules90-100.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Status :
+-----------------------------------+-----------------------------------+
|account_voucher | |
+-----------------------------------+-----------------------------------+
|analytic | |
|analytic | Done
+-----------------------------------+-----------------------------------+
|anonymization | |
+-----------------------------------+-----------------------------------+
Expand Down