Merge lp:~camptocamp/openerp-connector-magento/7.0-fix_1276645-afe into lp:~openerp-connector-core-editors/openerp-connector-magento/7.0

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Approved by: Guewen Baconnier @ Camptocamp
Approved revision: 958
Merge reported by: Guewen Baconnier @ Camptocamp
Merged at revision: not available
Proposed branch: lp:~camptocamp/openerp-connector-magento/7.0-fix_1276645-afe
Merge into: lp:~openerp-connector-core-editors/openerp-connector-magento/7.0
Diff against target: 17 lines (+5/-1)
1 file modified
magentoerpconnect/unit/backend_adapter.py (+5/-1)
To merge this branch: bzr merge lp:~camptocamp/openerp-connector-magento/7.0-fix_1276645-afe
Reviewer Review Type Date Requested Status
Romain Deheele - Camptocamp (community) code review Approve
Guewen Baconnier @ Camptocamp Approve
Review via email: mp+204988@code.launchpad.net

Description of the change

fix a crash when importing customers

if None is passed to magento_api.info for the attributes, then a very minimal list of attributes is returned. The argument must be omitted completely to get a standard list of attributes.

To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

tested on my customer's dev instance, works well.

958. By Alexandre Fayolle - camptocamp

[IMP] added comment to explain the fix

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Magento is supposed to handle correctly the Null value. The behavior you observe is probably due to an incompatibility between Magento 1.7 and PHP 5.4 (lp:1210775).

My only doubt here is that the magento library does the same thing that what you propose [0], so the authors could have a reason to do so and on the other hand, the other (similar) calls do not prevent to send Null [1] (and it becomes impossible when several positional arguments may be Null).

I will merge this one to be consistent with what the magento lib does.

Thanks for the report and proposal!

[0] https://github.com/openlabs/magento/blob/develop/magento/customer.py#L50
[1] https://github.com/openlabs/magento/blob/develop/magento/catalog.py#L56

review: Approve
Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

I have seen that with my own eyes.
LGTM,

Romain

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/unit/backend_adapter.py'
2--- magentoerpconnect/unit/backend_adapter.py 2013-06-26 06:36:58 +0000
3+++ magentoerpconnect/unit/backend_adapter.py 2014-02-06 07:17:50 +0000
4@@ -168,8 +168,12 @@
5
6 :rtype: dict
7 """
8+ arguments = [int(id)]
9+ if attributes: # don't pass a None in the attributes, otherwise you
10+ # only get a default almost empty list of attributes.
11+ arguments.append(attributes)
12 return self._call('%s.info' % self._magento_model,
13- [int(id), attributes])
14+ arguments)
15
16 def search_read(self, filters=None):
17 """ Search records according to some criterias