Skip to content

Conversation

@remytms
Copy link

@remytms remytms commented Apr 23, 2024

Merge project_status into project module. (OCA/project#1269)

Comment on lines 112 to 118
# We need to delete old project_status views
openupgrade.logged_query(
env.cr,
"DELETE FROM ir_ui_view WHERE model = 'project.project';"
)
Copy link
Author

Choose a reason for hiding this comment

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

This part may be a bit overkill. But I need to delete project_status views because there is references on old project.status model in it, and this causes the database to fail showing project views.

But views where renamed during updade of the base module, so I didn't find a way to distinguish between views that are part of existing project module and views coming from project_status and that were renamed.

I tried to remove old views by xmlids but this does not work. I think that this is because some xmlids ends up being the same after the renaming (e.g. project_status.edit_project and project.edit_project).

By using this, I force the update of project module to recreate views of the project.project model.

Any better way of doing it is welcome.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed this is not OK. Regular update process (the second pass without OpenUpgrade) must remove them being noupdate="0".

Copy link
Author

Choose a reason for hiding this comment

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

I tried not to delete project.project views, and perform a regular update after migration in 15.0.

I got the following logs:

2024-04-23 08:39:02,435 7 INFO brupower_upgrade odoo.addons.base.models.ir_module: ALLOW access to module.button_immediate_upgrade on ['Projet'] to user __system__ #1 via n/a 
2024-04-23 08:39:02,436 7 INFO brupower_upgrade odoo.addons.base.models.ir_module: ALLOW access to module.button_upgrade on ['Projet'] to user __system__ #1 via n/a 
2024-04-23 08:39:02,436 7 INFO brupower_upgrade odoo.addons.base.models.ir_module: ALLOW access to module.update_list on ['Projet'] to user __system__ #1 via n/a 
2024-04-23 08:39:09,805 7 INFO brupower_upgrade odoo.addons.base.models.ir_module: ALLOW access to module.button_install on [] to user __system__ #1 via n/a 
...
2024-04-23 08:39:19,078 7 INFO brupower_upgrade odoo.modules.loading: loading project/views/project_views.xml 
2024-04-23 08:39:19,253 7 WARNING brupower_upgrade odoo.addons.openupgrade_framework.odoo_patch.odoo.addons.base.models.ir_ui_view: Can't render custom view project.project_view_kanban for model project.project. Assuming you are migrating 
between major versions of Odoo. Please review the view contents manually after the migration.
Error: Element '<kanban class="o_kanban_mobile">' cannot be located in parent view 
2024-04-23 08:39:19,286 7 WARNING brupower_upgrade odoo.addons.openupgrade_framework.odoo_patch.odoo.addons.base.models.ir_ui_view: Can't render custom view project.project_view_kanban for model project.project. Assuming you are migrating 
between major versions of Odoo. Please review the view contents manually after the migration.
Error: Element '<kanban class="o_kanban_mobile">' cannot be located in parent view 
2024-04-23 08:39:19,325 7 INFO brupower_upgrade odoo.models.unlink: User #1 deleted ir.actions.act_window.view records with IDs: [336, 337] 
2024-04-23 08:39:19,593 7 WARNING brupower_upgrade odoo.addons.openupgrade_framework.odoo_patch.odoo.addons.base.models.ir_ui_view: Can't render custom view project.project_view_kanban for model project.project. Assuming you are migrating 
between major versions of Odoo. Please review the view contents manually after the migration.
Error: Element '<kanban class="o_kanban_mobile">' cannot be located in parent view 
2024-04-23 08:39:19,598 7 INFO brupower_upgrade odoo.modules.loading: loading project/views/res_partner_views.xml 
...

So it seams that I need to delete some views, but may be not all.

Copy link
Member

Choose a reason for hiding this comment

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

That's not a regular update, as openupgrade_framework is still around. Regular update will remove them.

Copy link
Author

Choose a reason for hiding this comment

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

Ho, yes indeed.

I've tested to deactivate views instead of deleting it, and it works also.

Copy link
Author

Choose a reason for hiding this comment

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

To perform a regular update after this migration in 15.0, I need to add a step to my migration process. Without deactivating views, if I go directly from a upgrade in 15.0 with openupgrade to an upgrade in 16.0 with openupgrade then upgrade in 16.0 with openupgrade fails.

Copy link
Member

Choose a reason for hiding this comment

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

Well, that shouldn't happen. It will emit the same warnings, but no crash.

Copy link
Author

Choose a reason for hiding this comment

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

I fixed it by just removing views that were overridden in the project_status module. And it works well.
Some standard views of project module were deleted in pre-migration script and then created fresh new by the update.

Copy link
Author

Choose a reason for hiding this comment

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

@pedrobaeza What do you think about the fix I proposed? It has been tested on a database for a real migration.

@remytms remytms force-pushed the 15.0-add-project_status branch 2 times, most recently from 294dcea to 8877eda Compare April 23, 2024 10:33
@legalsylvain legalsylvain added this to the 15.0 milestone Apr 25, 2024
@remytms remytms force-pushed the 15.0-add-project_status branch from f15c4de to f720786 Compare May 16, 2024 14:56
@remytms remytms force-pushed the 15.0-add-project_status branch from f720786 to c674c7e Compare May 27, 2024 07:57
},
)
# Delete project_status views
xmlids_views = [
Copy link
Member

Choose a reason for hiding this comment

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

I still don't see this as correct. Views are not a blocker for migration processes, and more deleting the whole inheritance chain. Please remove this part.

@enricostano
Copy link

Hi @remytms ! How can we help to move this forward? Thanks!

cc/ @juanmaGHub

@remytms
Copy link
Author

remytms commented Sep 23, 2024

Hi @remytms ! How can we help to move this forward? Thanks!

cc/ @juanmaGHub

@enricostano For me what needs to be done is setting up a migration test process like described by Pedro.

  • remove lines from this PR that removes views in pre-migration script
  • start from a database in 14.0 with project_status installed and some data.
  • migrate from 14.0 to 15.0 with openupgrade
  • perform an update all in 15.0 without openupgrade
  • migrate from 15.0 to 16.0 with openupgrade
  • perform an update all in 16.0 without openupgrade

Each step should work without ERRORS and the data of project_status must be correct in 16.0.

I've not found the time to perform such a test yet. Feel free to do it and report here.

@PicchiSeba
Copy link

PicchiSeba commented Dec 16, 2024

@remytms @pedrobaeza @enricostano

Hello everyone, I'm in the process of migrating an existing 14.0 installation to 16.0.

I created a test installation with just project_status in order to test this PR.
I also included the suggestions given by Pedro (I just commented out the elimination of the views from the migration script).

After the OpenUpgrade step I also upgraded the other modules as suggested.
The data is correctly migrated but the second upgrade fails because of an error in this incriminated view

Error: while parsing /opt/odoo/auto/addons/project/views/project_views.xml:552
Error while validating view:

Element '<kanban class="o_kanban_mobile">' cannot be located in parent view

View error context:
{'file': '/opt/odoo/auto/addons/project/views/project_views.xml',
 'line': 2,
 'name': 'project.project.kanban',
 'view': ir.ui.view(525,),
 'view.model': 'project.project',
 'view.parent': ir.ui.view(495,),
 'xmlid': 'project_view_kanban'}

I managed to fix the error by renaming the xmlid of the view to something else. I'm not sure why this fixes the error. The only thing that comes to mind is the fact the views involved have the same xmlid except for the module part.

In our case we might consider actually removing this specific view.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants