Contributors mailing list archives
contributors@odoo-community.org
Browse archives
Re: Module for uploading multiple images/attachments to website
Re: Module for uploading multiple images/attachments to website
Re: Module for uploading multiple images/attachments to website
by
InitOS GmbH, Pete Hahn
Hello Radovan, If I got you right you are asking for a one-time import job for migration, not for a front end based user friendly solution, right? If that’s the case the best way to do it is using the python shell interface for odoo and writing import scripts. Usual way we do stuff like this is to dump data from the old system in some structured way (access old DB, export to CSV/XML etc.) and read and transform using python scripts. Example for writing: ``` image_path = "/".join([self.image_base_path, path]) try: with Image.open(image_path) as image: buf = io.BytesIO() image.save(buf, format=image.format) b64_image = base64.b64encode(buf.getvalue()) return b64_image, basename(image_path) except FileNotFoundError as e: _logger.warning( f"Could not import image {image_path}", exc_info=_no_traceback(e)) ``` Attached is a simple script for reading. It just reads an image from a custom model. Doesn’t make sence for your case, but you can use this as a minimal starting example for the script and combine with the above code. If you use Odoo with buildout simply call: `bin/python_odoo <your_script.py> [your script arguments]` to run it. regards, Peter Am 13.10.20 um 16:36 schrieb Radovan Skolnik: > Nobody has anything on this? I really hate repetitive tasks - in this case > uploading images one by one. Isn't there a way for example to import > attachments? I've seen something like base64 encoding the content of image and > the provide it as content. But still needs to set Resource Model to ir.ui.view > which seems to be read only? Am I missing somethin crucial here? Any advice is > highly appreciated. Thank you. > Best regards > Radovan > On pondelok 28. septembra 2020 10:42:15 CEST Radovan Skolnik wrote: >> Hello, >> >> we are migrating old site (done in WordPress) into Odoo created site. I am >> looking for a way to upload and store multiple images for use in the >> migrated pages/blogs. So far I couldn't find a way to do this but I have a >> hunch I am missing something here :-) Any help is appreciated. Thank you. >> >> Best regards >> >> Radovan Skolnik > > > > _______________________________________________ > Mailing-List: https://odoo-community.org/groups/contributors-15 [1] > Post to: mailto:contributors@odoo-community.org > Unsubscribe: https://odoo-community.org/groups?unsubscribe [2] > > > > [1] https://odoo-community.org/groups/contributors-15 > [2] https://odoo-community.org/groups?unsubscribe >
Reference
-
Module for uploading multiple images/attachments to website
byData Dance s.r.o., Radovan Skolnik-
Re: Module for uploading multiple images/attachments to website
byData Dance s.r.o., Radovan Skolnik -
Re: Module for uploading multiple images/attachments to website
byClosingAp Open Source Integrators Europe, LDA, Daniel Reis -
Re: Module for uploading multiple images/attachments to website
byInitOS GmbH, Pete Hahn -
Re: Module for uploading multiple images/attachments to website
byData Dance s.r.o., Radovan Skolnik
-