-
Notifications
You must be signed in to change notification settings - Fork 78
[FIX] util/models: Fix constrain voilation #338
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
Closed
sagu-odoo
wants to merge
1
commit into
odoo:master
from
odoo-dev:master-fix_constraint_automation-sagu
Closed
[FIX] util/models: Fix constrain voilation #338
sagu-odoo
wants to merge
1
commit into
odoo:master
from
odoo-dev:master-fix_constraint_automation-sagu
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
dbd0427 to
2783203
Compare
aj-fuentes
reviewed
Oct 10, 2025
52d4388 to
33c9778
Compare
Contributor
|
upgradeci retry with always only base_automation base |
aj-fuentes
approved these changes
Oct 10, 2025
KangOl
reviewed
Oct 13, 2025
33c9778 to
7dd1e44
Compare
before 16.5 https://github.com/odoo/odoo/pull/114352/files#diff-f456849127002cd01a9e2058290e40ae8e5c1d57e15785699f0172400766bcd4R69 there was constraint on field ``action_server_id`` of ``base.automation`` model ON delete restrict https://github.com/odoo/odoo/blob/d07ffce41df433e51d1239be855cd52867b905e0/addons/base_automation/models/base_automation.py#L34C5-L34C21 which causing issue during upgrade when removing model if contextual action created for the same server action ``binding_model_id`` https://github.com/odoo/odoo/blob/3a28e5b0adbb36bdb1155a6854cdfbe4e7f9b187/odoo/addons/base/models/ir_actions.py#L35 as below mentioned traceback because due to on delete cascade model will remove.So, server action will also delete. But server action is linked to automated action. So, request will block. For fixing this issue removing the automated action first and then let the model remove. ``` Traceback (most recent call last): File "/home/odoo/src/odoo/16.0/odoo/service/server.py", line 1333, in preload_registries registry = Registry.new(dbname, update_module=update_module) File "<decorator-gen-16>", line 2, in new File "/home/odoo/src/odoo/16.0/odoo/tools/func.py", line 87, in locked return func(inst, *args, **kwargs) File "/home/odoo/src/odoo/16.0/odoo/modules/registry.py", line 87, in new odoo.modules.load_modules(registry, force_demo, status, update_module) File "/home/odoo/src/odoo/16.0/odoo/modules/loading.py", line 528, in load_modules migrations.migrate_module(package, 'end') File "/home/odoo/src/odoo/16.0/odoo/modules/migration.py", line 170, in migrate_module exec_script(self.cr, installed_version, pyfile, pkg.name, stage, stageformat[stage] % version) File "/home/odoo/src/odoo/16.0/odoo/modules/migration.py", line 188, in exec_script migrate(cr, installed_version) File "/tmp/tmpegkppsuy/migrations/sale_subscription/saas~15.3.1.1/end-migrate.py", line 20, in migrate util.remove_model(cr, "sale.subscription.line", drop_table=False) File "/tmp/tmpegkppsuy/migrations/util/models.py", line 222, in remove_model cr.execute("DELETE FROM ir_model WHERE id=%s", (mod_id,)) File "/home/odoo/src/odoo/16.0/odoo/sql_db.py", line 324, in execute res = self._obj.execute(query, params) psycopg2.errors.ForeignKeyViolation: update or delete on table "ir_act_server" violates foreign key constraint "base_automation_action_server_id_fkey" on table "base_automation" DETAIL: Key (id)=(3632) is still referenced from table "base_automation". ``` upg-3179507 opw-5148694
7dd1e44 to
c805d65
Compare
KangOl
approved these changes
Oct 13, 2025
Contributor
KangOl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robodoo r+
robodoo
pushed a commit
that referenced
this pull request
Oct 13, 2025
before 16.5 https://github.com/odoo/odoo/pull/114352/files#diff-f456849127002cd01a9e2058290e40ae8e5c1d57e15785699f0172400766bcd4R69 there was constraint on field ``action_server_id`` of ``base.automation`` model ON delete restrict https://github.com/odoo/odoo/blob/d07ffce41df433e51d1239be855cd52867b905e0/addons/base_automation/models/base_automation.py#L34C5-L34C21 which causing issue during upgrade when removing model if contextual action created for the same server action ``binding_model_id`` https://github.com/odoo/odoo/blob/3a28e5b0adbb36bdb1155a6854cdfbe4e7f9b187/odoo/addons/base/models/ir_actions.py#L35 as below mentioned traceback because due to on delete cascade model will remove.So, server action will also delete. But server action is linked to automated action. So, request will block. For fixing this issue removing the automated action first and then let the model remove. ``` Traceback (most recent call last): File "/home/odoo/src/odoo/16.0/odoo/service/server.py", line 1333, in preload_registries registry = Registry.new(dbname, update_module=update_module) File "<decorator-gen-16>", line 2, in new File "/home/odoo/src/odoo/16.0/odoo/tools/func.py", line 87, in locked return func(inst, *args, **kwargs) File "/home/odoo/src/odoo/16.0/odoo/modules/registry.py", line 87, in new odoo.modules.load_modules(registry, force_demo, status, update_module) File "/home/odoo/src/odoo/16.0/odoo/modules/loading.py", line 528, in load_modules migrations.migrate_module(package, 'end') File "/home/odoo/src/odoo/16.0/odoo/modules/migration.py", line 170, in migrate_module exec_script(self.cr, installed_version, pyfile, pkg.name, stage, stageformat[stage] % version) File "/home/odoo/src/odoo/16.0/odoo/modules/migration.py", line 188, in exec_script migrate(cr, installed_version) File "/tmp/tmpegkppsuy/migrations/sale_subscription/saas~15.3.1.1/end-migrate.py", line 20, in migrate util.remove_model(cr, "sale.subscription.line", drop_table=False) File "/tmp/tmpegkppsuy/migrations/util/models.py", line 222, in remove_model cr.execute("DELETE FROM ir_model WHERE id=%s", (mod_id,)) File "/home/odoo/src/odoo/16.0/odoo/sql_db.py", line 324, in execute res = self._obj.execute(query, params) psycopg2.errors.ForeignKeyViolation: update or delete on table "ir_act_server" violates foreign key constraint "base_automation_action_server_id_fkey" on table "base_automation" DETAIL: Key (id)=(3632) is still referenced from table "base_automation". ``` upg-3179507 opw-5148694 closes #338 Signed-off-by: Christophe Simonis (chs) <chs@odoo.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


before 16.5 there was constraint on field
action_server_idofbase.automationmodel ON delete restrict which causing issue during upgrade when removing model if contextual action created for the same server actionbinding_model_idas below mentioned traceback because due to on delete cascade model will remove.So, server action will also delete. But server action is linked to automated action. So, request will block.For fixing this issue removing the automated action first and then let the model remove.
upg-3179507
opw-5148694