Quantity error during export of invoice

Bug #1304426 reported by Andreas Brueckl
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenERP Connector - Magento
Confirmed
Undecided
Unassigned

Bug Description

Here is the error I get during the invoice export to magento when there are several positions of the same product in a magento-order:

Traceback (most recent call last):
  File "/opt/openerp/addons-enabled/connector/queue/worker.py", line 122, in run_job
    job.perform(session)
  File "/opt/openerp/addons-enabled/connector/queue/job.py", line 472, in perform
    self.result = self.func(session, *self.args, **self.kwargs)
  File "/opt/openerp/addons-enabled/magentoerpconnect/invoice.py", line 257, in export_invoice
    return invoice_exporter.run(record_id)
  File "/opt/openerp/addons-enabled/magentoerpconnect/invoice.py", line 180, in run
    mail_notification)
  File "/opt/openerp/addons-enabled/magentoerpconnect/invoice.py", line 131, in _export_invoice
    False)
  File "/opt/openerp/addons-enabled/magentoerpconnect/invoice.py", line 103, in create
    email, include_comment])
  File "/opt/openerp/addons-enabled/magentoerpconnect/invoice.py", line 90, in _call
    return super(AccountInvoiceAdapter, self)._call(method, arguments)
  File "/opt/openerp/addons-enabled/magentoerpconnect/unit/backend_adapter.py", line 135, in _call
    result = api.call(method, arguments)
  File "/usr/local/lib/python2.7/dist-packages/magento/api.py", line 161, in call
    return self.client.call(self.session, resource_path, arguments)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
    return u.close()
  File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close
    raise Fault(**self._stack[0])
Fault: <Fault 1: u'"Invalid qty to invoice item ""xxxxxxxx"""'>

If there is a order with several positions of the same product, then the method "_get_lines_info" in magentoerpconnect.invoice.MagentoInvoiceSynchronizer does not work correctly.

All quantities are sumed up, which results in the error message above

Revision history for this message
Andreas Brueckl (andreas-brueckl) wrote :

This patch addresses the problem with multiple lines which the same product_id.

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

Is it possible to have a sales order on Magento with several positions with the same product?
I tried and it always increment the existing position.

I'm not sure to understand what your patch is intended to do. How is item_qty.get(line.magento_id, False) related to the generator (I mean on each iteration it will have the same result)?

Thanks for your bug report and patch

Revision history for this message
Andreas Brueckl (andreas-brueckl) wrote :

You are right, with normal products this behaviour is not possible.
But if you have individual options for a certain product, you can have several lines with that product.

The patch assures, that a order_line which has already been considered in item_qty will not be considered for the next lines.
So each line in order.magento_order_line_ids is only selected once in the for-loop.

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

I got it.

Couldn't it be a problem if line A has 2 items and line B has 3 items, and the lines are reversed when sent to Magento?

Would you be so kind to create a merge proposal with your patch?

Changed in openerp-connector-magento:
status: New → Confirmed
Changed in openerp-connector-magento:
status: Confirmed → Fix Released
status: Fix Released → Won't Fix
status: Won't Fix → Confirmed
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.