This question has been flagged
1 Reply
4029 Views

Hello,

 

I fiddled around with the form view, as I wanted to add a second image to the product basic form.

 

Therefore, I first created the field:

  1. Settings - Databse Structure - Models
  2. searched for product.template
  3. Edited this model by adding a new field called "x_secondpicture" of type binary

Then, I activated the developer mode and wanted to edit the form view:

  1. Sales - Products - selected Form View - > "Manage Views"
  2. Selected "product.template.common.form" and clicked "edit"
  3. Found the node for the first image and clicked on "+" to insert a new node.

 

But now, I have two problems:

  1. For the second field, the widget "image" is not available - in fact no other widget except "manytomanyattendee" is available
  2. I inadvertently messed around with the original image node, and now I only have a download link available - I can't edit anything anymore.

Who can help?

 

 

 

 

Avatar
Discard
Author

I am not 100% sure if product.template.common.form is the view that i should have edited

Author

still no one who knows anything about this?

@Jörg, in regards to fixing the view, i'd recommend going to the runbots: runbot.odoo.com and checking the view that you have edited on the 8.0 test database. You should just be able to replace this modified view with the original/default from the runbots to be back to normal on your database. I'd recommend doing a database backup before making any changes to the database or installing a new module, as it makes it far easier to rollback once you inevitably break something during development/testing.

Author

Hello Luke, thank you for your answers, you helped me a lot. I will proceed as you recommended. Unfortunately, I do not have enough Karma to upvote your answers. Brgds Jörg

@Jörg, no problem. glad I could help.

Best Answer

@Jörg,

Could you post your module code to a public repository so that others can take a look? I've been working on another module to add multiple product images to product.template with the help of another developer that may be of interest to you:

https://github.com/OdooCommunityWidgets/website_multi_image/tree/8.0

If you are trying to add an image directly next to the other image widget on the product.template I think you will need to first check that you have your field inside product.template and then you will need to inherit the product_template_form_view and use xpath to insert your custom field directly after the following line:

<field name="image_medium" widget="image" class="oe_avatar oe_left"/>

I've built a very basic module to achieve what you've described above here:

https://github.com/lukebranch/product_images/tree/master

just do a:

sudo git clone https://github.com/lukebranch/product_images/tree/master 

in your /addons folder and install it and you should be good to go.

Avatar
Discard

on a side note, I would recommend making all customisations like this (custom fields, etc.) by creating your own custom module. Editing through the developer mode is not easily transferable to other databases and is not recommended if you're trying to add customisations.