Hi,
While am migrate my odoo 16 database from odoo 16 to Odoo 18 using the test upgrade button i get an error, how do i solve this?
class Attachment(models.Model):
_name = "travel_management.attachment"
_inherit = 'ir.attachment'
2025-11-24 06:56:07,023 23 CRITICAL db_3367148 odoo.service.server: Failed to initialize database `db_3367148`.
Traceback (most recent call last):
File "/home/odoo/src/odoo/17.0/odoo/service/server.py", line 1374, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "<decorator-gen-16>", line 2, in new
File "/home/odoo/src/odoo/17.0/odoo/tools/func.py", line 87, in locked
return func(inst, *args, **kwargs)
File "/home/odoo/src/odoo/17.0/odoo/modules/registry.py", line 110, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "/home/odoo/src/odoo/17.0/odoo/modules/loading.py", line 541, in load_modules
env['ir.model.data']._process_end(processed_modules)
File "/tmp/tmpww539keu/migrations/base/0.0.0/pre-models-no-model-data-delete.py", line 108, in _process_end
return super(IrModelData, self)._process_end(modules)
File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/ir_model.py", line 2593, in _process_end
self._process_end_unlink_record(record)
File "/home/odoo/src/odoo/17.0/addons/website/models/ir_model_data.py", line 36, in _process_end_unlink_record
return super()._process_end_unlink_record(record)
File "/home/odoo/src/odoo/17.0/odoo/addons/base/models/ir_model.py", line 2522, in _process_end_unlink_record
record.unlink()
File "/home/odoo/src/odoo/17.0/addons/mail/models/ir_model_fields.py", line 59, in unlink
return super().unlink()
File "/tmp/tmpww539keu/migrations/base/0.0.0/pre-models-ir_model.py", line 210, in unlink
raise util.MigrationError(message)
odoo.upgrade.util.exceptions.UpgradeError: 💥 It looks like you forgot to call `util.remove_field` on the following fields: travel_management.attachment.theme_template_id
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- โปรเจกต์
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
I hope you are doing well
Wrong model inheritance creates orphan fields during migration.
class Attachment(models.Model):
or add migration script (migrations/18.0.1.0.0/pre-migrate.py):
from odoo.upgrade import util
I hope this information helps you
Thanks & Regards,
Kunjan Patel
Hi,
Kunjan Patel. Thanks you for your answer, is this i need to write this in my Odoo 18 modules? not in the 16? since am getting this error before commiting the migrated modules. Can i write this same in the version 16 of that module?
What i need to know is that in which version of module i need to write this? since currently mu sh have the odoo 16 modules, and after migrating and the migration reached on the commit stage then only i will update the odoo 18 modules. But before that i need to fix this
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อ| Related Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
|---|---|---|---|---|
|
|
2
ต.ค. 24
|
2467 | ||
|
|
3
ต.ค. 23
|
3020 | ||
|
|
1
พ.ย. 25
|
1953 | ||
|
|
2
ก.ค. 25
|
5477 | ||
|
|
2
เม.ย. 25
|
1908 |
Hi,
Kunjan Patel. Thanks you for your answer, is this i need to write this in my Odoo 18 modules? not in the 16? since am getting this error before commiting the migrated modules. Can i write this same in the version 16 of that module?
Hello,
The odoo.upgrade.util module is only available in Odoo Enterprise upgrade scripts managed by Odoo SA. It won't work in your custom module migrations.
For custom module migrations, use this approach instead:
# migrations/18.0.1.0.0/pre-migrate.py
def migrate(cr, version):
# Remove orphaned field if needed
cr.execute("""
DELETE FROM ir_model_fields
WHERE model = 'ir.attachment'
AND name = 'theme_template_id'
AND module = 'travel_management'
""")
Hope it helps
Hello
Odoo.sh migration workflow:
1. Fix imports in your v18 branch first (before migration)
2. Push the v18-compatible code to v18 branch
3. Then trigger the migration on Odoo.sh
Odoo.sh runs migration using your v18 branch code, so imports must be v18-compatible before you start the upgrade - not after.