Open waltervargas opened 10 years ago
See #27 (comment)
Good day All, I encountered similar issue.
Traceback (most recent call last):
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/queue/queue_job/controllers/main.py", line 73, in runjob
self._try_perform_job(env, job)
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/queue/queue_job/controllers/main.py", line 32, in _try_perform_job
job.perform()
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/queue/queue_job/job.py", line 505, in perform
self.result = self.func(*tuple(self.args), **self.kwargs)
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/connector-prestashop/connector_prestashop/models/binding/common.py", line 66, in export_record
return exporter.run(self, fields)
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/connector-prestashop/connector_prestashop/components/exporter.py", line 51, in run
result = self._run(*args, **kwargs)
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/connector-prestashop/connector_prestashop/components/exporter.py", line 333, in _run
self.prestashop_id = self._create(record)
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/connector-prestashop/connector_prestashop_catalog_manager/models/product_template/exporter.py", line 37, in _create
res = super()._create(record)
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/connector-prestashop/connector_prestashop/components/exporter.py", line 256, in _create
return self.backend_adapter.create(data)
File "/media/trobz/c2c/rensales_odoo/odoo/external-src/connector-prestashop/connector_prestashop/components/backend_adapter.py", line 232, in create
res = self.client.add(
File "/opt/odoo/14_env/lib/python3.8/site-packages/prestapyt/prestapyt.py", line 348, in add
return self.add_with_url(full_url, content, files)
File "/opt/odoo/14_env/lib/python3.8/site-packages/prestapyt/prestapyt.py", line 636, in add_with_url
xml_content = dict2xml.dict2xml({'prestashop': content})
File "/opt/odoo/14_env/lib/python3.8/site-packages/prestapyt/dict2xml.py", line 124, in dict2xml
root, _ = _process_complex(doc, list(data.items()))
File "/opt/odoo/14_env/lib/python3.8/site-packages/prestapyt/dict2xml.py", line 76, in _process_complex
nodes = _process(doc, tag, value)
File "/opt/odoo/14_env/lib/python3.8/site-packages/prestapyt/dict2xml.py", line 54, in _process
nodelist, attrs = _process_complex(doc, list(tag_value.items()))
File "/opt/odoo/14_env/lib/python3.8/site-packages/prestapyt/dict2xml.py", line 76, in _process_complex
nodes = _process(doc, tag, value)
File "/opt/odoo/14_env/lib/python3.8/site-packages/prestapyt/dict2xml.py", line 56, in _process
node.appendChild(child)
File "/usr/lib/python3.8/xml/dom/minidom.py", line 114, in appendChild
if node.nodeType == self.DOCUMENT_FRAGMENT_NODE:
AttributeError: 'NoneType' object has no attribute 'nodeType'
That was because _process_complex
could not process this piece of data 'available_date': datetime.date(2021, 5, 24)
thus the node
was None
. Current fix is to convert the date to string before sending out.
# connector_prestashop_catalog_manager/models/product_template/exporter.py
class ProductTemplateExporter(Component):
# ...
@mapping
def available_date(self, record):
if record.available_date:
return {"available_date": record.available_date.strftime('%Y-%m-%d')}
return {}
The proposed solution is to add simple process for date and time as below.
# prestapyt/dict2xml.py
def _process(doc, tag, tag_value):
# ...
# Create a new node for simple values
fmt = []
if isinstance(tag_value, (datetime, date)):
fmt.append('%Y-%m-%d')
if isinstance(tag_value, (datetime, time)):
fmt.append('%H:%M:%S')
if fmt:
tag_value = tag_value.strftime(' '.join(fmt))
if (isinstance(tag_value, (float, int)) or
isinstance(tag_value, basestring)):
return _process_simple(doc, tag, tag_value)
# ...
Greetings Guewen,
I am have the next error when try to edit a record on prestashop:
I am doing this for edit a record on prestashoperpconnect.unit.backend_adapter:
Please help when you have time, I will try to fix it tomorrow, some advice ?
Thanks. Best Regards.