Merge lp://qastaging/~openerp-commiter/openobject-client/client-image-widget into lp://qastaging/openobject-client

Proposed by Nicolas DS
Status: Needs review
Proposed branch: lp://qastaging/~openerp-commiter/openobject-client/client-image-widget
Merge into: lp://qastaging/openobject-client
Diff against target: 723 lines (+583/-8) (has conflicts)
8 files modified
bin/widget/model/field.py (+1/-0)
bin/widget/view/common_gtk.py (+193/-0)
bin/widget/view/form_gtk/image.py (+18/-2)
bin/widget/view/form_gtk/many2one_image.py (+202/-0)
bin/widget/view/form_gtk/parser.py (+5/-5)
bin/widget/view/tree_gtk/image.py (+64/-0)
bin/widget/view/tree_gtk/many2one_image.py (+81/-0)
bin/widget/view/tree_gtk/parser.py (+19/-1)
Text conflict in bin/widget/view/form_gtk/image.py
Text conflict in bin/widget/view/tree_gtk/parser.py
To merge this branch: bzr merge lp://qastaging/~openerp-commiter/openobject-client/client-image-widget
Reviewer Review Type Date Requested Status
Christophe Simonis (OpenERP) Needs Fixing
Stephane Wirtel (OpenERP) Pending
Review via email: mp+23325@code.qastaging.launchpad.net

Description of the change

* Add image widget for Tree.image (and so for Form.M2M too), Tree.M2O_image, Form.M2O_image
* Add more image format support.

Pictures of those new widgets in action:
* http://zyphos.be/openobject/img_widget_tree.jpg (Tree.image)
* http://zyphos.be/openobject/M2O_img_widget_tree.jpg (Tree.many2one_image)
* http://zyphos.be/openobject/M2O_img_widget_form.jpg (Form.many2one_image)

See branch description for more details.

To post a comment you must log in.
Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :

I don't get it. I don't see why you need to define a new widget ? Is keeping widget="image" not enough, and just handle the case where this is display in tree view? Beeing displayed into a x2many [1] is not a special case.

[1] this is a one2many, not a many2one. And only for this error, the merge is in "Needs Fixing"

review: Needs Fixing
Revision history for this message
Nicolas DS (zyphos) wrote :

In GTK client all widget are separated by view. And the "Tree.image" does NOT exist for now in GTK client.

This branch is keeping widget="image" for image in Tree view, Form view and many2many in Form view (of course it is a tree view embedded in a screen view that acts as a form widget.).

In GTK client, "Tree view" widget are a lot different from "Form" one indeed:
- You need to define a new kind of cell renderer for special content. (It's not as easy as Form view)
- GTK treeview widget is asking a LOT of time to refresh row and column. (2 times to show the widget and then each time the mouse pointer get over, get out of any cell.)

In any refresh with the standard widget you need to: get the image data, compute the pixbuf (GTK image), then rescale the pixbuf to fit into screen. Those operations are very CPU/bandwidth intensive, that's why those widget need to be cached (for 120sec defined in bin/widget/view/common_gtk.py @line 137).

The problem with caching is the fact that if the image change in DB, the client will see the change maximum 120 sec further, and not in real time. Real time is still working for the basic "Form.image" widget.

At first I tried to use the widget="image" for many2one, but it's impossible in widget definition in openobject to know where type of field data come from.
Indeed widget python code is called from:
client/bin/widget/view/form_gtk/parser.py @line 416
widget_act = widgets_type[type][0](self.window, self.parent, model, fields[name])

and "type" is not alway the original field type, indeed:
@line 401
type = attrs.get('widget', fields[name]['type'])

and the many2one image widget needs to search for a binary field to get the data from.

I don't understand your one2many thing, I didn't made any one2many widget, if you look into source you will see that many2one_image is inheriting from the many2one class. So even if the many2one original class is a one2many I am lost.

The only fixing I see could be a different caching time or avoiding this caching time. But the best solution would be to create some kind of "push on field content change" from server to the client. But this feature needs a persistent connection to the server.
http://en.wikipedia.org/wiki/Push_technology

Or another one is to store hash of binary fields to quickly see if the image content has changed without eating lot of resource (CPU/bandwidth).

Don't forget to have a look at branch description for more information how this branch is working:
https://code.launchpad.net/~openerp-commiter/openobject-client/client-image-widget

Thank you for your review.

Revision history for this message
Christophe Simonis (OpenERP) (kangol) wrote :

After seeing you example module, I see what you try to do with the many2one_image.
You are doing it wrong. You have to create a related field on your object and use it with widget="image"

I modify your code (untested):
http://sprunge.us/MhFQ?python
http://sprunge.us/EfKA?xml

review: Needs Fixing
Revision history for this message
Nicolas DS (zyphos) wrote :

You are right for the Tree.many2one_image widget !
I must admit that I never used field.related before ;)
It acts like the one I created.

But for the Form.many2one_image the purpose isn't the same.

The Form.many2one_image represent a M2O object, so you can change the M2O relation directly, with your solution you will directly change the showed image itself and not the M2O relation.

1214. By Nicolas DS

[MERGE] from official trunk GTK client

1215. By Nicolas DS

[IMP] get_pixbuf and get_thumbnail support multi id query

1216. By Nicolas DS

[FIX] image-widget: Typos + Making code more robust

1217. By Nicolas DS

[REF] Form.M2O_image widget

1218. By Nicolas DS

[IMP] Added clear button for the form.M2O_image widget

1219. By Nicolas DS

[IMP] form.M2O_image code clean up

Unmerged revisions

1219. By Nicolas DS

[IMP] form.M2O_image code clean up

1218. By Nicolas DS

[IMP] Added clear button for the form.M2O_image widget

1217. By Nicolas DS

[REF] Form.M2O_image widget

1216. By Nicolas DS

[FIX] image-widget: Typos + Making code more robust

1215. By Nicolas DS

[IMP] get_pixbuf and get_thumbnail support multi id query

1214. By Nicolas DS

[MERGE] from official trunk GTK client

1213. By Nicolas DS

[FIX] Bug due to model field change

1212. By Nicolas DS

[FIX] M2O image find and get

1211. By Nicolas DS

[FIX] Case when M2O relation is empty

1210. By Nicolas DS

[MERGE] From trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.