AttributeError: 'NoneType' object has no attribute 'translate'

Bug #603634 reported by Nautica
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magento OpenERP Connector
Invalid
Undecided
Unassigned

Bug Description

Overnight i updated Magento to latest version 1.4.1.0. Strange is that the first order that came with the latest version was imported wihout a problem. The second order however triggered this error:

Environment Information :
System : Windows-32bit
OS Name : nt
Operating System Release :
Operating System Version : 32bit
Operating System Architecture : 32bit
Operating System Locale : nl_NL.cp1252
Python Version : 2.5.2
OpenERP-Client Version : 5.0.10
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "netsvc.pyo", line 245, in dispatch
  File "netsvc.pyo", line 74, in __call__
  File "service\web_services.pyo", line 576, in execute
  File "osv\osv.pyo", line 58, in wrapper
  File "osv\osv.pyo", line 119, in execute
  File "osv\osv.pyo", line 111, in execute_cr
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\base_sale_multichannels\sale.py", line 199, in import_orders
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\magerp\sale.py", line 114, in import_shop_orders
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\magerp\magerp_osv.py", line 255, in mage_import_base
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\base_external_referentials\external_osv.py", line 155, in ext_import
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\magerp\sale.py", line 367, in oevals_from_extdata
  File "C:\Users\Proline\OpenERP AllInOne\Server\addons\magerp\sale.py", line 286, in get_order_addresses
AttributeError: 'NoneType' object has no attribute 'translate'

Any hints where to look?

Revision history for this message
Nautica (nautica1959) wrote :

Sorry but my foldername is magerp instead of magentoerpconnect. I still did not changed it and made that name when i started it in the beginning of this project when the first release had still the name from smile.

Line 286 in magentoerpconnect/sale.py has this line:

vat = data_record['customer_taxvat'].translate(allchars, delchars).upper() an takes the value from the sales_flat_order table ( new table name in Magento 1.4.1.0) form the field customer_taxvat.
The value in that field for the first order to import was (NULL). When i removed the (NULL) and had just an empty field i was able to import the order.

This is strange because all previous orders from Magento 1.4.0.1 that had a (NULL) value I had no problems of importing the orders.

So I think the code snippet:

if cr.fetchone() and 'customer_taxvat' in data_record:
            allchars = string.maketrans('', '')
            delchars = ''.join([c for c in allchars if c not in string.letters + string.digits])
            vat = data_record['customer_taxvat'].translate(allchars, delchars).upper()
            vat_country, vat_number = vat[:2].lower(), vat[2:]
            check = getattr(partner_obj, 'check_vat_' + vat_country)
            vat_ok = check(vat_number)

Should contain an if statement when NOT NULL

Revision history for this message
Nautica (nautica1959) wrote :

To make it work again I changed line 283 in magentoerpconnect/sale.py

from

if cr.fetchone() and 'customer_taxvat' in data_record:

to:

if cr.fetchone() and 'customer_taxvat' in data_record and data_record['customer_taxvat'] != None:

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Which version of the connector do you use?
Do you still have the bug?
Best regards

Changed in magentoerpconnect:
status: New → Incomplete
Changed in magentoerpconnect:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

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