Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration scripts for v13 #1733

Closed
pedrobaeza opened this issue Feb 7, 2019 · 44 comments
Closed

Migration scripts for v13 #1733

pedrobaeza opened this issue Feb 7, 2019 · 44 comments

Comments

@pedrobaeza
Copy link
Member

pedrobaeza commented Feb 7, 2019

(del) means that the module has been removed in this version
(add) means that the module has been added in this version
> means that it has been identified that the module has been renamed to the name below
< means that it has been identified that the module has been rename from the name below
-> means that the module has been merged in the module below
<- means that the module is the target where the module below has been merged

OCA has funded the development of the migration scripts that are installed in their Odoo instance. They are marked as (OCA project) for being recognized and expect them to be done in the near future if not yet done.

*- modules (deletions):

@legalsylvain
Copy link
Contributor

Hi @pedrobaeza and @mreficent.
Thanks a lot for this work !

@OthmaneGhandi
Copy link

We appreciate your efforts ! Big Thanks

@pedrobaeza pedrobaeza pinned this issue Jul 3, 2019
@rafaelbn
Copy link
Member

Then @pedrobaeza the method is say here:

Hey! We don't need to migrate https://github.com/OCA/website/tree/12.0/website_canonical_url because Odoo did it in v13 here odoo/odoo#35852

Is it?

@pedrobaeza
Copy link
Member Author

Yes, that's it, but as it's still a PR, we don't annotate yet in the main issue

@sudhir-erpharbor
Copy link

@pedrobaeza You already know this. I think we should add this in the description.

selection key must be of type string like: [('0', 'Zero'), ('1', 'One')] and cannot be number like: [(0, 'Zero'), (1, 'One')]

See discussion and source commit: odoo/odoo#28891

@pedrobaeza
Copy link
Member Author

@sudhir-erpharbor thanks for the info. I'm afraid this can't be treated in a general way, and should be handled in each module that was using numbers and know need strings, as selection values may change as well. The strategy should be:

  • Rename column.
  • Let Odoo to create the new varchar selection column (or be created by us in advance).
  • Map values from one column to another.

@dupski
Copy link

dupski commented Oct 12, 2019

Great stuff @pedrobaeza

What is the process for creating the migration script for v13? Are there some folks already working on them on a branch somewhere? I'm keen to help if I can!

@pedrobaeza
Copy link
Member Author

There's no written process for creating such scripts yet, but there are plenty of examples in previous versions scripts. For now there's no more work on this.

@norlinhenrik
Copy link

I see here that the base modules were migrated to 12.0 in December 2018. So far I see here no modules migrated to 13.0. Would be nice to have a list like this for 13.0 to follow the progress.

@ivantodorovich
Copy link

I'd like to contribute to this project, but I'm a bit lost.
How can we know which tasks have are pending / done / in progress ?

@legalsylvain
Copy link
Contributor

Hi @ivantodorovich. Thanks for your interest in openUpgrade.

First, you can take a look on that documentation :

Then, the basic process to migrate a module for 12.0 to 13.0 is :

Propose a PR !

That's all !

You can ping @pedrobaeza, @StefanRijnhart, or other contributors if you have any questions.

kind regards.

@braincrewapps

This comment has been minimized.

@pedrobaeza

This comment has been minimized.

@wpichler
Copy link

wpichler commented Mar 9, 2020

Hi all,

what is the current state of the openupgrade migration to v13 ? Does anyone here has a working branch for this already - where we can help ?

kind regards.

@StefanRijnhart
Copy link
Member

@wpichler just check the open PRs as well as recently merged PRs with target tag 13.0: https://github.com/OCA/OpenUpgrade/pulls?q=is%3Apr+milestone%3A13.0+

Currently that is only base and some basic dependencies, so if you want to help please pick a module that is next up in the hierarchy chain and start writing the migration scripts!

@pedrobaeza
Copy link
Member Author

@kos94ok-3D if you plan to work on other migration scripts, better to say in advance for coordinating and not duplicating efforts

@kos94ok-3D
Copy link

Hi, @pedrobaeza.
I interested in the migration of Stock, Purchase, and Manufacturing. (Not sure about an Accounting)
And I want to start from Product and Stock.

@pedrobaeza
Copy link
Member Author

We are going to work on all of them (my colleague @MiquelRForgeFlow is already in fact and have some draft scripts), so if you want to wait, just review ours. All depends on your deadlines. We want to finish all across April.

@kos94ok-3D
Copy link

Ok. I can wait.

@pedrobaeza
Copy link
Member Author

FYI I have changed the default branch in the repo to 13.0 now that we are starting to have some base.

@Yasaie
Copy link
Member

Yasaie commented Apr 7, 2020

Hello,

I just tried to migrate mass_mailing but i saw mail.mass_mailing.campaign merged into utm.campaign. I looked into openupgradelib and i find move_field_m2o function but in this case mail.mass_mailing.campaign will be removed before migration so I copied mail_mass_mailing_campaign in pre-migration.py:

from openupgradelib import openupgrade

_table_renames = [
    # removed tables
    ('mail_mass_mailing_campaign', None),
]


@openupgrade.migrate()
def migrate(env, version):
    openupgrade.rename_tables(env.cr, _table_renames)

then I changed move_field_m2o to work with table in post-migration and did like below:

from openupgradelib import openupgrade

def move_table_m2o(
        cr, table_old_model, field_old_model,
        m2o_field_old_model, table_new_model, field_new_model):
    cr.execute(
        " SELECT %s"
        " FROM %s"
        " GROUP BY %s"
        " HAVING count(*) = 1;" % (
            m2o_field_old_model, table_old_model, m2o_field_old_model
        ))
    ok_ids = [x[0] for x in cr.fetchall()]
    query = (
            " UPDATE %s as new_table"
            " SET %s=("
            "    SELECT old_table.%s"
            "    FROM %s as old_table"
            "    WHERE old_table.%s=new_table.id"
            "    LIMIT 1) "
            " WHERE id in %%s" % (
                table_new_model, field_new_model, field_old_model,
                table_old_model, m2o_field_old_model))
    openupgrade.logged_query(cr, query, [tuple(ok_ids)])


def move_campaign_fields(cr):
    table_old_model = openupgrade.get_legacy_name('mail.mass_mailing.campaign')
    table_new_model = 'utm_campaign'
    m2o_field_old_model = 'campaign_id'
    
    move_table_m2o(cr, table_old_model, 'color', m2o_field_old_model, table_new_model, 'color')


@openupgrade.migrate()
def migrate(env, version):
    move_campaign_fields(env.cr)

Now i just want to know is this the correct way? or maybe some changes in openupgradelib's move_field_m2o in:
https://github.com/OCA/openupgradelib/blob/deee08f0cc401a966045d302e97ee50b00483158/openupgradelib/openupgrade.py#L1790
might works as well.

I some models in another module this problem came to me. so it's a general question not just for this module

@MiquelRForgeFlow
Copy link
Contributor

MiquelRForgeFlow commented Apr 7, 2020

Sorry, I see now you did a PR with the thing you commented. Thanks.

@gdgellatly
Copy link

@pedrobaeza
I have a very simple 12.0 -> 13.0 migration which can live test a lot of open PR's. At rough count there is only 3 module difference and I can probably do those in a few hours.

What is the process for something like sale_management where there is nothing to do. Do I just need to create a PR with the work.txt file and updating the module file?

@pedrobaeza
Copy link
Member Author

Yes, that's it, @gdgellatly

@pedrobaeza
Copy link
Member Author

This is something to be taken into account for the migration:

odoo/odoo#49354

@MiquelRForgeFlow
Copy link
Contributor

@pedrobaeza but that's not a migration issue as I understand. I mean, the problem they are facing is for newly created databases in v13. But the ones coming from v12 are ok, they have that xmlid.

@pedrobaeza
Copy link
Member Author

Read again that there's a part about recreating on migration the XML-ID.

@fmdl
Copy link

fmdl commented Apr 27, 2020

@pedrobaeza where we can help for accounting migration ?

@pedrobaeza
Copy link
Member Author

There's already a PR for it and I'm now checking it in deeply, but no result of my review will be available until finished. Please wait a bit.

@mr-module
Copy link

I have been working on v12 to v13 migration of db using openupgrade. All the data is transferred but invoices are not displayed.
Anyone have any idea on this?

@BartvandenHout
Copy link

I have been working on v12 to v13 migration of db using openupgrade. All the data is transferred but invoices are not displayed.
Anyone have any idea on this?

Some fields from the old account.invoice are not yet transferred. You are not seeing any invoices because the 'type' on account.move is all set to 'entry' instead of 'out_invoice', 'out_refund', etc. On account.move.line the price_unit, price_subtotal, price_total are not set, as is exclude_from_invoice_tab (NULL) (for showing in Invoice Lines or in Journal Items). There's more to be done, like invoice date, salesperson.

@mr-module
Copy link

@BartvandenHout thanks for the response.
But, how do I see invoices in my v13 db?
it's all empty in invoices but in v12 there are all invoices.

@BartvandenHout
Copy link

@mr-module
Probably best to wait for until OpenUpgrade finished the account-migration. Then do the migration from v12 to v13 again.

@mr-module
Copy link

@BartvandenHout when can we expect this to be done?

@BartvandenHout
Copy link

@mr-module For now I'm just a user like you. But I also am eager to get the v13-migration done. That's why I'm looking at the database, what is still needed and the OpenUpgrade-code to see if I can help the developers a bit.

@mr-module
Copy link

@BartvandenHout
Thanks for the update.

@stepanetssergey
Copy link

I have same issue with invoices after migration to odoo13. Can somebody suggest how to fix it?

@mr-module
Copy link

mr-module commented Aug 20, 2020 via email

@stepanetssergey
Copy link

Thanks. But I need to fix it to Monday :(

@mr-module
Copy link

mr-module commented Aug 20, 2020 via email

@edoodev20
Copy link

@pedrobaeza ! is there any update about the invoices migration..

@kos94ok-3D
Copy link

@pedrobaeza Could you update the status for modules that were migrated?
mrp_byproduct merged into mrp
website: #2299
website_blog: #2374
website_crm: #2573
website_hr_recruitment: #2532
website_payment: #2569
website_sale: #2294
website_sale_comparison: #2575
website_sale_delivery: #2572
website_sale_management: #2574

@BojanOD
Copy link

BojanOD commented Nov 19, 2022

I have been working on v12 to v13 migration of db using openupgrade. All the data is transferred but invoices are not displayed.
Anyone have any idea on this?

Some fields from the old account.invoice are not yet transferred. You are not seeing any invoices because the 'type' on account.move is all set to 'entry' instead of 'out_invoice', 'out_refund', etc. On account.move.line the price_unit, price_subtotal, price_total are not set, as is exclude_from_invoice_tab (NULL) (for showing in Invoice Lines or in Journal Items). There's more to be done, like invoice date, salesperson.

Is this issue resolved, can someone provide me with additional information on how to migrate from v12 to v13 without losing any customer invoices?

@pedrobaeza
Copy link
Member Author

We can consider it completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests