Order import error: float() argument must be a string or a number

Bug #1164951 reported by Robert Rübner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magento OpenERP Connector
New
Undecided
Unassigned

Bug Description

Hi all,

- magentoerpconnect: revision 685 from oerp6.1-stable branch
- Magento: 1.6.0.0 using only simple products

I get the following error on order import in OpenERP 6.1

(u'Error with the mapping : shipping_amount_tax_included. Error details : float() argument must be a string or a number',)
Traceback (most recent call last):
  File "/opt/openerp/htdocs/openerp/addons/base_external_referentials/decorator.py", line 130, in wrapper
    response = func(self, import_cr, uid, external_session, resource, *args, **kwargs)
  File "/opt/openerp/htdocs/openerp/addons/base_sale_multichannels/sale.py", line 614, in _record_one_external_resource
    defaults=defaults, mapping=mapping, mapping_id=mapping_id, context=context)
  File "/opt/openerp/htdocs/openerp/addons/base_external_referentials/external_osv.py", line 704, in _record_one_external_resource
    vals = self._transform_one_resource(cr, uid, external_session, 'from_external_to_openerp', resource, mapping=mapping, mapping_id=mapping_id, defaults=defaults, context=context)
  File "/opt/openerp/htdocs/openerp/addons/base_external_referentials/decorator.py", line 49, in wrapped
    return func(self, cr, uid, argument, *args, **kwargs)
  File "/opt/openerp/htdocs/openerp/addons/magentoerpconnect/sale.py", line 425, in _transform_one_resource
    previous_result=previous_result, defaults=defaults, context=context)
  File "/opt/openerp/htdocs/openerp/addons/base_external_referentials/external_osv.py", line 1426, in _transform_one_resource
    raise MappingError(e, mapping_line['name'], self._name)
MappingError: the mapping line: shipping_amount_tax_included for the object sale.order has this error: float() argument must be a string or a number

Problem is that resource.get('shipping_discount_amount', 0.0) is None in mapping lines.

I fixed it this way:
I replaced the following lines in settings/1.5.0.0/sale.order/external.mappinglines.template.csv

from

mag1500_sale_order_shipping_amount_tax_included=>,,in,function,base_shipping_incl_tax,,float,False,mag1500_sale_order,shipping_amount_tax_included,"amount_tax_inc = float(resource.get('base_shipping_incl_tax', 0.0)) - float(resource.get('shipping_discount_amount', 0.0))
amount_tax_exc = float(resource.get('shipping_amount', 0))

to

mag1500_sale_order_shipping_amount_tax_included=>,,in,function,base_shipping_incl_tax,,float,False,mag1500_sale_order,shipping_amount_tax_included,"
shipping_discount_amount = resource.get('shipping_discount_amount', 0.0)
if shipping_discount_amount is None:
    shipping_discount_amount = 0.0
amount_tax_inc = float(resource.get('base_shipping_incl_tax', 0.0)) - float(shipping_discount_amount)
amount_tax_exc = float(resource.get('shipping_amount', 0))

Regards
Robert

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.