Hi
I am still working (should you remember some other questions i made) on my extension of the fleet module.
I changed my objectives somehow, and now i need to know how to write the following in the new V8 style:
def _get_image(self, cr, uid, ids, name, args, context=None):
result = dict.fromkeys(ids, False)
for obj in self.browse(cr, uid, ids, context=context):
result[obj.id] = tools.image_get_resized_images(obj.image)
return resultdef _set_image(self, cr, uid, id, name, value, args, context=None):
return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)_columns = {
'image': fields.binary("Foto",
help="limited to 1024x1024px."),
'image_medium': fields.function(_get_image, fnct_inv=_set_image,
string="Medium size picture", type="binary", multi="_get_image",
store = {
'fleet.vehicle': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
},
help="128x128px"\
"forms and kanban."),
'image_small': fields.function(_get_image, fnct_inv=_set_image,
string="small sized picture", type="binary", multi="_get_image",
store = {
'fleet.vehicle': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
},
help="64x64px"\
"Use for small pictures"),
}
I need this in order to be able to correctly extend the fleer.vehicle model (it originally has image/image_medium/image_small programed as related fields to the brand logo, but now i changed them to this in order to be able to set my own picture for each vehicle).
I made my modifications directly to the fleet.py file, because my own module is written in V8 style, and i lack the knowledge to adapt all that to the new style.
So, my first request is help in adapting them, because i need to further add image fields (binary fields) to this model, and i don't like having to directly work on fleet.py because of the different style.
Also, those functions are there to adapt the image i load into the "image" field for the 128x128 and 64x64 for the medium and small size ones.
It would be GREAT if i could make my own function in order to also resize to other sizes (384x384 and 512x512 come to mind).
As an alternative, a way to take the "image" field and do somethign in XML or CSS (i have cero CSS knowledge tho), so that i can limit bigger image size for some form views. Currently, if i add the "image" field that HAS to accept bigger pictures (user happiness, not that they will ever be shown) to a form view, their display is totally broken.
Finally, is there any way to add "expand on click" or "open in a new windows on click" or "something on click" to image fields, so that in any posible way i can click on a smaller image and get to see it's bigger version?
I no longuer need to adapt anything (seems too hard), cause i can extend the same model in my module in 2 different files, using the new api style in one, and the old one in the other. The only thing i don't know how to do is to "override a function to do nothing" (the "on_change_model" function is no longer needed, cause that was the one that fetched the picture from the brand.). What did now was create multiple image fields (image-engine, image-engine_medium, for example). I am strugling to adapt/create/use the image adapting functions odoo provides (they are in tools/image.py). Just copying the "get" and "set" functions and changing them to use the new fields is not enought, as far as i could see. If i just do that, when i CREATE a new car, the pictures are stored in the new fields, without resizing. Then, if i edit the car and add/cahnge pictures, nothing happens. If i just use the "image-engine" filed in the XML instead of the "medium" one that uses the functions, i can properly "edit" the car, but still, i get big pictures, when i want to use the resize functions.