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

[FIX] models: fix filters model_id correclty #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sagu-odoo
Copy link
Contributor

@sagu-odoo sagu-odoo commented Dec 27, 2024

This kind of where clause is preparing due to that while merging models filters model_id is not updating

NOT EXISTS(SELECT 1 FROM ir_filters o WHERE o.user_id = t.user_id AND o.action_id = t.action_id AND o.name = t.name AND o.model_id=%(new)s)
AND NOT EXISTS(SELECT 1 FROM ir_filters o WHERE true AND o.model_id=%(new)s)

because while checking not exist SELECT 1 FROM ir_filters o WHERE true AND o.model_id=%(new)s there are filters exist of new model(in that model is merging) due to this condition didn't fulfill and model_id is set as _unknown during remove call( because here it didn't updated before remove_model method call). This above mentioned condition should be there if Indirect reference res_model it self have the unique constraint. So, that is only on ir_model handled accordingly like ir_model have model field which have unique constraint.

original record

 select id,model_id from ir_filters where id in (100,210,101,87,194,103,214,105,202,177,178,207) ;
 id  |     model_id
-----+-------------------
  87 | sale.subscription
 100 | sale.subscription
 101 | sale.subscription
 103 | sale.subscription
 105 | sale.subscription
 210 | sale.subscription
 177 | sale.subscription
 178 | sale.subscription
 194 | sale.subscription
 202 | sale.subscription
 207 | sale.subscription
 214 | sale.subscription

before fix

sagu_2403383_upg=> select id,model_id from ir_filters where id in (100,210,101,87,194,103,214,105,202,177,178,207) ;
 id  | model_id
-----+----------
  87 | _unknown
 100 | _unknown
 101 | _unknown
 178 | _unknown
 103 | _unknown
 105 | _unknown
 202 | _unknown
 177 | _unknown
 194 | _unknown
 207 | _unknown
 210 | _unknown
 214 | _unknown
(12 rows)

after fix

sagu_2403383_17.0=> select id,model_id from ir_filters where id in (100,210,101,87,194,103,214,105,202,177,178,207) ;
 id  |  model_id
-----+------------
  87 | sale.order
 100 | sale.order
 101 | sale.order
 103 | sale.order
 105 | sale.order
 177 | sale.order
 178 | sale.order
 194 | sale.order
 202 | sale.order
 207 | sale.order
 210 | sale.order
 214 | sale.order

opw-4381532

@robodoo
Copy link
Contributor

robodoo commented Dec 27, 2024

Pull request status dashboard

@sagu-odoo sagu-odoo requested review from a team and filisbits December 27, 2024 08:53
This kind of where clause is preparing due to that
while merging model filters are not updating
```
NOT EXISTS(SELECT 1 FROM ir_filters o WHERE o.user_id = t.user_id AND o.action_id = t.action_id AND o.name = t.name AND o.model_id=%(new)s)
AND NOT EXISTS(SELECT 1 FROM ir_filters o WHERE true AND o.model_id=%(new)s)
```
because while checking not exist
``SELECT 1 FROM ir_filters o WHERE true AND o.model_id=%(new)s``
there are filters exist of new model(in that model is merging)
due to this condition didn't fulfill and ``model_id`` is set as ``_unknown``
during remove call. this condition should be there if Indirect reference ``res_model``
it self have the unique constraint. So, that is only on ir_model handled accordingly.

original record
```
 select id,model_id from ir_filters where id in (100,210,101,87,194,103,214,105,202,177,178,207) ;
 id  |     model_id
-----+-------------------
  87 | sale.subscription
 100 | sale.subscription
 101 | sale.subscription
 103 | sale.subscription
 105 | sale.subscription
 210 | sale.subscription
 177 | sale.subscription
 178 | sale.subscription
 194 | sale.subscription
 202 | sale.subscription
 207 | sale.subscription
 214 | sale.subscription

```

before fix
```
sagu_2403383_upg=> select id,model_id from ir_filters where id in (100,210,101,87,194,103,214,105,202,177,178,207) ;
 id  | model_id
-----+----------
  87 | _unknown
 100 | _unknown
 101 | _unknown
 178 | _unknown
 103 | _unknown
 105 | _unknown
 202 | _unknown
 177 | _unknown
 194 | _unknown
 207 | _unknown
 210 | _unknown
 214 | _unknown
(12 rows)
```

after fix
```
sagu_2403383_17.0=> select id,model_id from ir_filters where id in (100,210,101,87,194,103,214,105,202,177,178,207) ;
 id  |  model_id
-----+------------
  87 | sale.order
 100 | sale.order
 101 | sale.order
 103 | sale.order
 105 | sale.order
 177 | sale.order
 178 | sale.order
 194 | sale.order
 202 | sale.order
 207 | sale.order
 210 | sale.order
 214 | sale.order
```

opw-4381532
@sagu-odoo sagu-odoo force-pushed the master-fix_model_id_assign-sagu branch from 4bb5081 to 7e6a999 Compare December 31, 2024 10:22
@sagu-odoo
Copy link
Contributor Author

Hello @odoo/upgrade , could you please review the pr ?
Thanks in advance 🐈‍⬛

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.

2 participants