[Typo][6.1/Trunk] binary field in tree view messes with new objects
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Web (MOVED TO GITHUB) |
Fix Released
|
Medium
|
OpenERP R&D Web Team |
Bug Description
This bug is difficult to reproduce in the runbot as I'm not aware of binary fields appearing in tree view.
But we use binary fields in tree view. And we found that the code was probably never run even once as there are obvious typo in the code giving an direct wrong feedback.
The typo
------------
This typo was found in openerp 6.1 but is also in last 7.0.
Here is a proposed patch for the typo found in 6.1 in ``addons/
@@ -331,10 +349,10 @@ openerp.
}
}
- return _.template('<a href="<
+ return _.template('<a href="<
text: text,
href: download_url,
size: row_data[
Notice the '<%-size%>'.
In 7.0, the same typo is found:
$ rgrep '%<-size%>' .
./addons/
The wrong size
-------
If you correct the obvious typo, the size displayed is the base64 content of the file !. (despite the field was called "size" in the javascript dictionnary, it is filled with the wrong value.)
This seem very related to this bug: https:/
The prevention of the creation of a new element
-------
Even when using '<%-size%>', correcting the size displays. The creation of a new element will fail. This probably only occur in form nested tree views displaying binary field.
The javascript code do not receive a real object id, and thus cannot create the url:
download_url = _.str.sprintf(
as ``options.id`` is not a real integer id, but a string. Which will cast an exception as it can't be matched with "%d".
This leads to a javascript uncaught exception preventing the object from being created.
I didn't try to reproduce these bad behaviour on 7.0, but it seems that the code was only quickly moved around without ever being tested (the ugly template typo is a good marker to see that this code was never run in 6.1 when it was written, and in 7.0 when it was moved around.)
If more info is needed, or the report is unclear, please comment.
Related branches
description: | updated |
summary: |
- binary field in tree view messes with new objects and has typo + [Typo][6.1/Trunk] binary field in tree view messes with new objects |
Changed in openerp-web: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
assignee: | nobody → OpenERP R&D Web Team (openerp-dev-web) |
description: | updated |
> The typo
fixed in Revision:
3394 revid:<email address hidden>
> The wrong size
In the mentioned case, the web client uses the bin_size key in the context. When bin_size is used, the server returns the size of the blob instead of the base64 representation. So this bug should be reported in the server branch in a separate bug report.
> The prevention of the creation of a new element
Fixed in Revision:
3397 revid:<email address hidden>
While testing, I also noticed that binary fields in tree view embedded in a o2m displayed the base64 instead of the download link.
This has been fixed in Revision:
3396 revid:<email address hidden>