Commit 7a2f0bb
[FIX] fastapi: Flush before exiting Fastapi environment
As the fastapi dispatcher is altering the public request's
environment before calling the endpoint, it will reuse
the same DB cursor from this environment.
Therefore, if fields are being marked to be recomputed during
the execution of the fastapi endpoint, these will not be
recomputed until the cursor is being commited, what happens
when we are not anymore authenticated through as fastapi user.
This means the recomputation of computed fields will be executed
with the public user, what could potentially lead to inconsistencies
or result in an AccessError.
By calling flush before exiting the contextmanager yielding
the altered Odoo environment, we ensure all the pending
computations are executed while being authenticated with
the fastapi user which must have more access rights than the
public user.1 parent 4b8bb1d commit 7a2f0bb
1 file changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
0 commit comments