← Back to team overview

openerp-chinese-team team mailing list archive

[Merge] lp:~openerp-chinese-team/magentoerpconnect/guest-order-bug-fix into lp:magentoerpconnect/oerp6.1-stable

 

Joshua Jan(SHINEIT) has proposed merging lp:~openerp-chinese-team/magentoerpconnect/guest-order-bug-fix into lp:magentoerpconnect/oerp6.1-stable.

Requested reviews:
  MagentoERPConnect core editors (magentoerpconnect-core-editors)
Related bugs:
  Bug #1054059 in Magento OpenERP Connector: "Importing Guest-Orders is not possible (KeyError: 'shop_id' in create_onfly_partner on line 387)"
  https://bugs.launchpad.net/magentoerpconnect/+bug/1054059

For more details, see:
https://code.launchpad.net/~openerp-chinese-team/magentoerpconnect/guest-order-bug-fix/+merge/131813

Hello all,
    There are two change to fix the https://bugs.launchpad.net/magentoerpconnect/+bug/1054059
    Another one:
    https://code.launchpad.net/~openerp-chinese-team/e-commerce-addons/guest-order-bug-fix
Best Regards
Joshua
 
-- 
https://code.launchpad.net/~openerp-chinese-team/magentoerpconnect/guest-order-bug-fix/+merge/131813
Your team Open ERP Chinese is subscribed to branch lp:~openerp-chinese-team/magentoerpconnect/guest-order-bug-fix.
=== modified file 'magentoerpconnect/sale.py'
--- magentoerpconnect/sale.py	2012-08-20 09:39:45 +0000
+++ magentoerpconnect/sale.py	2012-10-29 03:13:18 +0000
@@ -401,15 +401,17 @@
                      mapping_line_filter_ids=None, parent_data=None, previous_result=None, defaults=None, context=None):
         resource = self.clean_magento_resource(cr, uid, resource, context=context)
         resource = self.clean_magento_items(cr, uid, resource, context=context)
-        if not resource['customer_id']:
+        if not resource.get('customer_id', False):
             #If there is not partner it's a guest order
             #So we remove the useless information
             #And create a partner on fly and set the data in the default value
-            del resource['customer_id']
-            del resource['billing_address']['customer_id']
-            del resource['shipping_address']['customer_id']
+            if 'customer_id' in resource:
+                del resource['customer_id']
+            if 'customer_id' in resource['billing_address']:
+                del resource['billing_address']['customer_id']
+            if 'customer_id' in resource['shipping_address']:
+                del resource['shipping_address']['customer_id']
             defaults = self.create_onfly_partner(cr, uid, external_session, resource, mapping, defaults, context=context)
-
         return super(sale_order, self)._transform_one_resource(cr, uid, external_session, convertion_type, resource,\
                  mapping, mapping_id,  mapping_line_filter_ids=mapping_line_filter_ids, parent_data=parent_data,\
                  previous_result=previous_result, defaults=defaults, context=context)
@@ -624,7 +626,7 @@
         # in the sale order and sometime it's equal to NONE in the address but at least the
         # the information is correct in one of this field
         # So I make this ugly code to try to fix it.
-        if not resource['customer_id']:
+        if not resource.get('customer_id', False):
             if resource['billing_address'].get('customer_id'):
                 resource['customer_id'] = resource['billing_address']['customer_id']
         else:


Follow ups