100
100
if context is None: context = {}
101
101
logger = netsvc.Logger()
102
102
conn = context.get('conn_obj', False)
103
carrier = self.pool.get('delivery.carrier').read(cr, uid, carrier_id, ['magento_code', 'magento_tracking_title'], context)
103
carrier = self.pool.get('delivery.carrier').read(cr, uid, carrier_id, ['magento_carrier_code', 'magento_tracking_title'], context)
105
105
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
106
106
carrier_tracking_ref = self.read(cr, uid, id, ['carrier_tracking_ref'], context)['carrier_tracking_ref']
108
108
carrier_tracking_ref = ''
110
# in Magento, the delivery method is something like that:
111
# tntmodule2_tnt_basic
112
# where the first part before the _ is always the carrier code
113
# in this example, the carrier code is tntmodule2
114
carrier_code = carrier['magento_code'].split('_')[0]
116
res = conn.call('sales_order_shipment.addTrack', [ext_shipping_id, carrier_code, carrier['magento_tracking_title'] or '', carrier_tracking_ref or ''])
110
res = conn.call('sales_order_shipment.addTrack', [ext_shipping_id, carrier['magento_carrier_code'], carrier['magento_tracking_title'] or '', carrier_tracking_ref or ''])
118
logger.notifyChannel('ext synchro', netsvc.LOG_INFO, "Successfully adding a tracking reference to the shipping with OpenERP id %s and ext id %s in external sale system" % (id, ext_shipping_id))
112
logger.notifyChannel('ext synchro', netsvc.LOG_INFO, "Successfully adding a tracking reference to the shipping with OpenERP id %s and ext id %s in external sale system" % (id, ext_shipping_id))