Commit 0eb4088
committed
[ADD] fields/make_field_non_stored
opw-4502675
When a field becomes non-stored, the associated column must be removed during
the upgrade.
Unless the field remains selectable, such removal will cause `ir.filters`
relying on such field to fail. This commit introduces a new util to clean up
user-defined filters. In order to do that, the relevant part of the
`remove_field` util is factored out into a new private method.
---
Example of problem, with reproducer:
`account.account`'s `group_id` field has become non-stored[^1] in 18.0,
therefore:
1. Create db in 17.0, with `account` installed;
2. Create user-defined default filter on model `account.account`, with domain
containing `group_id`. Example: `{"group_by", ["group_id"]}`;
3. Upgrade db to 18.0
4. Open chart of account (and select filter, if not automatically selected)
Error should look something like the following:
```
RPC_ERROR
Odoo Server Error
Occured on localhost:8069 on model account.account and id 6 on 2025-02-06 09:34:41 GMT
Traceback (most recent call last):
File "/home/odoo/src/odoo/18.0/odoo/http.py", line 1957, in _transactioning
return service_model.retrying(func, env=self.env)
File "/home/odoo/src/odoo/18.0/odoo/service/model.py", line 137, in retrying
result = func()
File "/home/odoo/src/odoo/18.0/odoo/http.py", line 1924, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/home/odoo/src/odoo/18.0/odoo/http.py", line 2172, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "/home/odoo/src/odoo/18.0/odoo/addons/base/models/ir_http.py", line 329, in _dispatch
result = endpoint(**request.params)
File "/home/odoo/src/odoo/18.0/odoo/http.py", line 727, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "/home/odoo/src/odoo/18.0/addons/web/controllers/dataset.py", line 35, in call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odoo/src/odoo/18.0/odoo/api.py", line 517, in call_kw
result = getattr(recs, name)(*args, **kwargs)
File "/home/odoo/src/odoo/18.0/addons/web/models/models.py", line 243, in web_read_group
groups = self._web_read_group(domain, fields, groupby, limit, offset, orderby, lazy)
File "/home/odoo/src/odoo/18.0/addons/web/models/models.py", line 269, in _web_read_group
groups = self.read_group(domain, fields, groupby, offset=offset, limit=limit,
File "/home/odoo/src/odoo/18.0/odoo/models.py", line 2858, in read_group
rows = self._read_group(domain, annotated_groupby.values(), annotated_aggregates.values(), offset=offset, limit=limit, order=orderby)
File "/home/odoo/src/odoo/18.0/odoo/models.py", line 1973, in _read_group
groupby_terms: dict[str, SQL] = {
File "/home/odoo/src/odoo/18.0/odoo/models.py", line 1974, in <dictcomp>
spec: self._read_group_groupby(spec, query)
File "/home/odoo/src/odoo/18.0/odoo/models.py", line 2090, in _read_group_groupby
sql_expr = self._field_to_sql(self._table, fname, query)
File "/home/odoo/src/odoo/18.0/addons/account/models/account_account.py", line 184, in _field_to_sql
return super()._field_to_sql(alias, fname, query, flush)
File "/home/odoo/src/odoo/18.0/odoo/models.py", line 2946, in _field_to_sql
raise ValueError(f"Cannot convert {field} to SQL because it is not stored")
ValueError: Cannot convert account.account.group_id to SQL because it is not stored
The above server error caused the following client error:
OwlError: An error occured in the owl lifecycle (see this Error's "cause" property)
Error: An error occured in the owl lifecycle (see this Error's "cause" property)
at handleError (http://localhost:8069/web/assets/fd2cc33/web.assets_web.min.js:959:101)
at App.handleError (http://localhost:8069/web/assets/fd2cc33/web.assets_web.min.js:1610:29)
at ComponentNode.initiateRender (http://localhost:8069/web/assets/fd2cc33/web.assets_web.min.js:1051:19)
Caused by: RPC_ERROR: Odoo Server Error
RPC_ERROR
at makeErrorFromResponse (http://localhost:8069/web/assets/fd2cc33/web.assets_web.min.js:3134:163)
at XMLHttpRequest.<anonymous> (http://localhost:8069/web/assets/fd2cc33/web.assets_web.min.js:3139:13)
```
[^1]:
https://github.com/odoo/upgrade/blob/6197269809a7007fd7eadfc8fb6d2c6a83bc5ca4/migrations/account/saas~17.5.1.2/pre-migrate.py#L97
closes #208
Related: odoo/upgrade#7177
Signed-off-by: Christophe Simonis (chs) <[email protected]>1 parent f53e454 commit 0eb4088
1 file changed
+87
-68
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
120 | 124 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
129 | 146 | | |
130 | | - | |
131 | 147 | | |
| 148 | + | |
132 | 149 | | |
133 | 150 | | |
134 | 151 | | |
| |||
142 | 159 | | |
143 | 160 | | |
144 | 161 | | |
145 | | - | |
146 | | - | |
147 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
148 | 178 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 179 | + | |
| 180 | + | |
155 | 181 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 182 | + | |
162 | 183 | | |
163 | | - | |
164 | | - | |
165 | 184 | | |
166 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
167 | 203 | | |
168 | 204 | | |
169 | 205 | | |
170 | 206 | | |
171 | | - | |
| 207 | + | |
172 | 208 | | |
173 | 209 | | |
174 | 210 | | |
175 | 211 | | |
176 | 212 | | |
177 | 213 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 214 | + | |
211 | 215 | | |
212 | 216 | | |
213 | 217 | | |
| |||
372 | 376 | | |
373 | 377 | | |
374 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
375 | 394 | | |
376 | 395 | | |
377 | 396 | | |
| |||
0 commit comments