Skip to content

Commit

Permalink
Merge pull request #63 from tarunbhardwaj/shipping-line-6815
Browse files Browse the repository at this point in the history
Pick shipping product from carrier on importing sale_order #6815
  • Loading branch information
prakashpp committed Jan 29, 2015
2 parents df5cecc + a7b7f40 commit 358e4f1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,31 @@ def get_shipping_line_data_using_magento_data(cls, order_data):
:param order_data: Order Data from magento
"""
Uom = Pool().get('product.uom')
MagentoCarrier = Pool().get('magento.instance.carrier')

carrier_data = {}
unit, = Uom.search([('name', '=', 'Unit')])

# Fetch carrier code from shipping_method
# ex: shipping_method : flaterate_flaterate
# carrier_code : flaterate
carrier_data['code'], _ = order_data['shipping_method'].split('_', 1)

magento_carrier = MagentoCarrier.find_using_magento_data(carrier_data)

if magento_carrier and magento_carrier.carrier:
product = magento_carrier.carrier.carrier_product
else:
product = None

return ('create', [{
'description': 'Magento Shipping',
'description': order_data['shipping_description'] or
'Magento Shipping',
'product': product,
'unit_price': Decimal(order_data.get('shipping_amount', 0.00)),
'unit': unit.id,
'note': ' - '.join([
'Magento Shipping',
order_data['shipping_method'],
order_data['shipping_description']
]),
Expand Down

0 comments on commit 358e4f1

Please sign in to comment.