OCA / multi-company

GNU Affero General Public License v3.0
100 stars 281 forks source link

[PROBLEM] Migration from v15 to v16 #546

Closed phayasqs closed 9 months ago

phayasqs commented 9 months ago

Hello everyone

I am upgrading my Odoo database from v15 to v16. Inside i am using base_multi_company, partner_multi_company, product_multi_company I found proper code for all of these modules in v16 but have no idea how i can upgrade all of them without losing a data. Because of the init_hook's inside i am trying to force them to run when updating these modules (with migrate functions[post exactly]). My migrate functon is running init_hook's when updating code but still something is wrong:

File "/home/odoo/src/user/base_multi_company/hooks.py", line 50, in post_init_hook table_name = model._fields["company_ids"].relation KeyError: 'company_ids'

It is happenning with model = res.partner() All modules in v16 are installed but i was only upgrading them not reinstalling.

I would really appreciate for any advice.

phayasqs commented 9 months ago

I've identified the issue. In this context, there is no requirement to execute migrations and run init_hooks. Instead, we can simply uninstall and reinstall the 'partner_multi_company' and 'product_multi_company' modules. There was no need to uninstall 'base_multi_company.'

The problem I encountered was the inability to view all partners from version 15. This issue arose because, in version 15, partners with an empty 'company_ids' field were still visible to all companies. However, in the current version, a partner is not visible if the 'company_ids' field is empty. To resolve this, I expanded the 'partner_multi_company' init_hook and added a function to fill empty 'company_ids' with the IDs of all companies from 'res.company'.

pedrobaeza commented 9 months ago

The error seems to be on your upgrading mechanism, that is not loading the proper modules. Closing, as this is not an issue of the module itself.