Merge lp:~camptocamp/openerp-connector-magento/7.0-image-1258418-gbr into lp:~openerp-connector-core-editors/openerp-connector-magento/7.0

Proposed by Guewen Baconnier @ Camptocamp on 2013-12-18
Status: Merged
Approved by: Guewen Baconnier @ Camptocamp on 2014-01-14
Approved revision: 936
Merged at revision: 940
Proposed branch: lp:~camptocamp/openerp-connector-magento/7.0-image-1258418-gbr
Merge into: lp:~openerp-connector-core-editors/openerp-connector-magento/7.0
Diff against target: 39 lines (+4/-4)
2 files modified
magentoerpconnect/product.py (+3/-3)
magentoerpconnect/tests/test_import_product_image.py (+1/-1)
To merge this branch: bzr merge lp:~camptocamp/openerp-connector-magento/7.0-image-1258418-gbr
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp code review, no tests 2013-12-18 Approve on 2014-01-14
Review via email: mp+199537@code.launchpad.net

Commit message

[FIX] the main image has the 'image' type, not 'base'

Description of the change

To post a comment you must log in.
Stefaan Ferket (s-ferket) wrote :

This one works perfect for us. It now takes the image that we expected.

LGTM

review: Approve (code review, no tests)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'magentoerpconnect/product.py'
--- magentoerpconnect/product.py 2013-11-09 23:01:40 +0000
+++ magentoerpconnect/product.py 2013-12-18 19:33:00 +0000
@@ -259,7 +259,7 @@
259259
260 def _sort_images(self, images):260 def _sort_images(self, images):
261 """ Returns a list of images sorted by their priority.261 """ Returns a list of images sorted by their priority.
262 An image with the 'base' type is the the primary one.262 An image with the 'image' type is the the primary one.
263 The other images are sorted by their position.263 The other images are sorted by their position.
264264
265 The returned list is reversed, the items at the end265 The returned list is reversed, the items at the end
@@ -267,11 +267,11 @@
267 """267 """
268 if not images:268 if not images:
269 return {}269 return {}
270 # place the images where the type is 'base' first then270 # place the images where the type is 'image' first then
271 # sort them by the reverse priority (last item of the list has271 # sort them by the reverse priority (last item of the list has
272 # the the higher priority)272 # the the higher priority)
273 def priority(image):273 def priority(image):
274 primary = 'base' in image['types']274 primary = 'image' in image['types']
275 try:275 try:
276 position = int(image['position'])276 position = int(image['position'])
277 except ValueError:277 except ValueError:
278278
=== modified file 'magentoerpconnect/tests/test_import_product_image.py'
--- magentoerpconnect/tests/test_import_product_image.py 2013-09-03 09:55:45 +0000
+++ magentoerpconnect/tests/test_import_product_image.py 2013-12-18 19:33:00 +0000
@@ -70,7 +70,7 @@
70 """ Check if the images are sorted in the correct priority """70 """ Check if the images are sorted in the correct priority """
71 env = mock.Mock()71 env = mock.Mock()
72 importer = CatalogImageImporter(env)72 importer = CatalogImageImporter(env)
73 file1 = {'file': 'file1', 'types': ['base'], 'position': '10'}73 file1 = {'file': 'file1', 'types': ['image'], 'position': '10'}
74 file2 = {'file': 'file2', 'types': ['thumbnail'], 'position': '3'}74 file2 = {'file': 'file2', 'types': ['thumbnail'], 'position': '3'}
75 file3 = {'file': 'file3', 'types': ['thumbnail'], 'position': '4'}75 file3 = {'file': 'file3', 'types': ['thumbnail'], 'position': '4'}
76 file4 = {'file': 'file4', 'types': [], 'position': '10'}76 file4 = {'file': 'file4', 'types': [], 'position': '10'}