Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [MIG] product_multi_image: Module totally redone from old product_images #57

Closed
wants to merge 2 commits into from

Conversation

pedrobaeza
Copy link
Member

This is still a work in progress.

Refactorized:

  • Take into account templates and products
  • Code for creating and updating
  • Views
  • All!

New planned features:

  • Three possible sources: URL, file or DB.
  • Possibility to share images between different products.
  • New kanban view
  • Others not yet thought.

@api.one
def unlink(self):
if self.path:
os.path.isfile(self.path) and os.remove(self.path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unlikely to happen but there is a small chance that 2 calls are done at the same time, one call will raise an OSError. I think the line could be replaced by the following because we do not mind if it does no longer exist.

try:
    os.remove(self.path)
except OSError:
    pass

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think the file should be deleter after the call to super, so if something raise in super, the file won't be deleted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thanks.

@bealdav
Copy link
Member

bealdav commented Apr 9, 2015

@sebastienbeau, take a look, you have done job on this matter

@flotho
Copy link
Member

flotho commented Aug 20, 2015

Hi,

I don't understand the problem with runbot.
The issue seems to come from the dataset that has already 2 codes identical.
Any chance to be explained what is the process to change this?

@LeartS
Copy link

LeartS commented Aug 21, 2015

I forced a rebuild, let's see what happens.

@LeartS
Copy link

LeartS commented Aug 21, 2015

Well, seems to be an error due to the module product_sequence. The strange thing is that module has some code specifically to handle this case: https://github.com/OCA/product-attribute/blob/8.0/product_sequence/models/product_product.py#L26

Maybe it never gets called? I see the module partner_firstname uses _install_<module-name> to do something similar.

flotho added a commit to MindAndGo/product-attribute that referenced this pull request Aug 21, 2015
Those part dispappeared from the PR and was present in the OCA repo.
This code reintegrate the missing part
OCA#57 (comment)
@flotho
Copy link
Member

flotho commented Aug 21, 2015

Hi @LeartS

Thanks for your report.
Actually the branch from @pedrobaeza missed this part of code.
So I made this pedrobaeza#1
Once it will be pulled we'll be able to rerun the test.

Thanks

@LeartS
Copy link

LeartS commented Aug 21, 2015

@flotho I've just noticed that this PR is older than that code, @pedrobaeza should just rebase this branch and it should fix itself.

@flotho
Copy link
Member

flotho commented Aug 21, 2015

@LeartS
Ok sorry, I didn't checked well your comment, I did it for @pedrobaeza, we only have to wait now.

@pedrobaeza
Copy link
Member Author

Branch rebased. Let's see CIs' result.

@flotho
Copy link
Member

flotho commented Aug 25, 2015

Hi,

I don't understand the reason of the runbot built failure. It talks about mrp, yet there is no mrp in this PR.

@flotho
Copy link
Member

flotho commented Sep 11, 2015

Any chance to have some odoo core updates and rerun this one?

flotho added a commit to MindAndGo/product-attribute that referenced this pull request Sep 15, 2015
Those part dispappeared from the PR and was present in the OCA repo.
This code reintegrate the missing part
OCA#57 (comment)
@rafaelbn
Copy link
Member

cc @yajo @sergio-incaser @carlos-incaser


This module implements the possibility to have multiple images for a product,
that it's to say, an image gallery.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing some important parts such as usage instructions, try on runbot, report issues, etc.

self.name = self._make_pretty(self.name)

@api.onchange('path')
def onchange_path(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please prefix with _ following guidelines.

@yajo
Copy link
Member

yajo commented Oct 29, 2015

Full code review done for now, with some remarks as you see. You did 828 additions and 448 deletions, some tests would be appreciated. Also please fix runbot to start functional review. Thanks!

@pedrobaeza
Copy link
Member Author

@yajo, that was done a lot of time ago. My skills have improved since then 😉 I'll check your comments later

def _check_url(self):
if self.type == 'url' and not self.url:
raise exceptions.ValidationError(
'You must provide a URL for the product image.')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a URL or an URL?

@yajo
Copy link
Member

yajo commented Oct 30, 2015

I'm thinking of another approach, let's see what you think.

What about putting all the gallery-related stuff in an abstract model in a separate module, and then inherit it in products and add the views?

I'm sure with time more and more models will benefit of having a gallery (events, blog...). This way we'd reuse the abstract one and repeat less code.

@pedrobaeza
Copy link
Member Author

Yeah, it's a very good idea. We need them 2 modules: base_multi_image, with all the stuff that handles the possible sources, cache... and then inherit in product_multi_image, event_multi_image... Are you going to do it?

@yajo
Copy link
Member

yajo commented Oct 30, 2015

Let's ask @rafaelbn.

@rafaelbn
Copy link
Member

I agree, let's go. Please, talking about images they must be stored outside data base. How to solve this?

@pedrobaeza
Copy link
Member Author

For now, there's 3 possibilities:

  • Store in database
  • Put a path of the file server. This is located outside of the DB, but the file handling is made outside Odoo.
  • Put a URL. This is for avoiding making verbatim copies of images, if you already have them on another hosting (like in Magento, Prestashop...).

We can add a fourth option that is "stored as a attachment".

@yajo
Copy link
Member

yajo commented Nov 2, 2015

I'm forking this to develop. Close for now if you wish.

@pedrobaeza
Copy link
Member Author

OK, eager to see the new approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants