-
Notifications
You must be signed in to change notification settings - Fork 23.1k
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] web: handle computed stored binary fields #156673
[FIX] web: handle computed stored binary fields #156673
Conversation
64bc21d
to
26cda0b
Compare
26cda0b
to
0d23781
Compare
@rco-odoo Hi, cwg proposed this fix for the issue but as he's on leave he suggested I ping you :) Should normally be safe (still trying to figure out the one access error case), and it's especially useful as in most cases where you have a computed binary you probably want to store it to avoid having to recompute it every time (as I would guess most computed binaries should imply a heavy computation). We need it for a new app that's supposed to target 17.0 so would be nice to merge it there, plus the issue is introduced in that version anyway. |
Currently if you have a computed stored binary field calling `web_save` will save the "bin_size" value to database instead of correctly storing the computed data. This is due to the cache being updated in web_read, at the end of web_save, before the values of the create/write are ever flushed. As web_read is called with bin_size=True for efficiency, this leads to _write using the newly cached size as the value, instead of the value passed to web_save.
0d23781
to
9869551
Compare
Hello @reth-odoo , Proposal:#160708 |
That's fine, so long as we can find some kind of solution :p |
fixed in ryv's proposal |
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes odoo#156673 Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes #156673 closes #160708 Signed-off-by: Raphael Collet <rco@odoo.com> Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes #156673 closes #160708 Signed-off-by: Raphael Collet <rco@odoo.com> Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes #156673 closes #160708 Signed-off-by: Raphael Collet <rco@odoo.com> Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes odoo#156673 Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes #156673 Part-of: #163634 Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes odoo#156673 X-original-commit: 400790e Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes odoo#156673 X-original-commit: 400790e Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes odoo#156673 closes odoo#160708 Signed-off-by: Raphael Collet <rco@odoo.com> Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes #156673 X-original-commit: 400790e Part-of: #164061 Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes #156673 X-original-commit: 400790e Part-of: #164045 Co-authored-by: Renaud Thiry <reth@odoo.com>
When bin_size=True is in the context, a computed non-attachment binary is incorrectly saved to the database. The row is actually updated with the size of the binary instead of the value itself. This commit fixes the problem by avoiding setting the cache with the bin_size value as dirty. Moreover, the binary size is computed with `pg_size_pretty` for non-attachment binary fields. Also, method compute_value() calls b64decode() on the value that was previously encoded in base64 by _compute_datas(). But _compute_datas() is specific to attachments, and is not used in this case. Thus b64decode() doesn't make sense. These 3 bugs are now covered by testing web_save(), where cache consistency is required. It was first reported for this method. Closes odoo#156673 X-original-commit: 400790e Part-of: odoo#164061 Co-authored-by: Renaud Thiry <reth@odoo.com>
Currently if you have a computed stored binary field, calling web_save will save the "bin_size" value to database instead of correctly storing the computed data.
Everything goes well until
web_read
triggers a re-compute with bin_size=True, this leadscompute_value
inclass Binary(field)
to store the "bin_size" value in cache.As the compute from web_save has not yet been flushed by this point, the
_write
that happens afterweb_save
is completed will use the new cache value instead of the one we want.Issue is mitigated by flushing before the web_read.
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr