Merge lp:~magentoerpconnect-core-editors/magentoerpconnect/oerp6.1-oldstable-nocheck_tracking-1108643 into lp:magentoerpconnect/oerp6.1-oldstable

Proposed by Guewen Baconnier @ Camptocamp
Status: Needs review
Proposed branch: lp:~magentoerpconnect-core-editors/magentoerpconnect/oerp6.1-oldstable-nocheck_tracking-1108643
Merge into: lp:magentoerpconnect/oerp6.1-oldstable
Diff against target: 45 lines (+10/-7)
1 file modified
magentoerpconnect/stock.py (+10/-7)
To merge this branch: bzr merge lp:~magentoerpconnect-core-editors/magentoerpconnect/oerp6.1-oldstable-nocheck_tracking-1108643
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+145324@code.launchpad.net

Commit message

[FIX] do not check if the carrier exists in getCarrier if there is no tracking number, do not send an empty tracking number

Description of the change

Fix for bug lp:1108643

Skip the check and creation of a tracking number if the tracking number is empty.
Currently, the check prevent to export a picking if the carrier is not in the
Magento's 'getCarriers' list.

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Don't we want to have at least something logged telling us that something is not correctly configured?

review: Needs Information
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)

Unmerged revisions

666. By Guewen Baconnier @ Camptocamp

[FIX] do not check if the carrier exists in getCarrier if there is no tracking number, do not send an empty tracking number

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'magentoerpconnect/stock.py'
2--- magentoerpconnect/stock.py 2012-06-27 15:44:07 +0000
3+++ magentoerpconnect/stock.py 2013-01-29 08:38:22 +0000
4@@ -79,12 +79,16 @@
5 :param str picking_type: 'partial' or 'complete'
6 :return: the picking id on magento
7 """
8- sale = self.browse(cr, uid, id, context=context).sale_id
9+ picking = self.browse(cr, uid, id, context=context)
10+ sale = picking.sale_id
11 magento_incrementid = sale.magento_incrementid
12 carrier_id = self.read(cr, uid, id, ['carrier_id'], context)['carrier_id']
13 if carrier_id:
14 carrier_id = carrier_id[0]
15- self.pool.get('delivery.carrier').check_ext_carrier_reference(cr, uid, carrier_id, magento_incrementid, context)
16+
17+ if carrier_id and picking.carrier_tracking_ref:
18+ self.pool.get('delivery.carrier').check_ext_carrier_reference(
19+ cr, uid, carrier_id, magento_incrementid, context)
20
21 ext_shipping_id = False
22 meth = getattr(self, "create_ext_%s_shipping" % picking_type)
23@@ -106,7 +110,7 @@
24 else:
25 raise
26
27- if ext_shipping_id and carrier_id:
28+ if ext_shipping_id and carrier_id and picking.carrier_tracking_ref:
29 self.add_ext_tracking_reference(cr, uid, id, carrier_id, ext_shipping_id, context)
30 return ext_shipping_id
31
32@@ -116,10 +120,9 @@
33 conn = context.get('conn_obj', False)
34 carrier = self.pool.get('delivery.carrier').read(cr, uid, carrier_id, ['magento_carrier_code', 'magento_tracking_title'], context)
35
36- if self.pool.get('ir.model.fields').search(cr, uid, [('name', '=', 'carrier_tracking_ref'), ('model', '=', 'stock.picking')]): #OpenERP v6 have the field carrier_tracking_ref on the stock_picking but v5 doesn't have it
37- carrier_tracking_ref = self.read(cr, uid, id, ['carrier_tracking_ref'], context)['carrier_tracking_ref']
38- else:
39- carrier_tracking_ref = ''
40+ carrier_tracking_ref = self.read(cr, uid, id,
41+ ['carrier_tracking_ref'],
42+ context)['carrier_tracking_ref']
43
44 res = conn.call('sales_order_shipment.addTrack', [ext_shipping_id, carrier['magento_carrier_code'], carrier['magento_tracking_title'] or '', carrier_tracking_ref or ''])
45 if res: