Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong attribute name for the shipping line builder #114

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion magentoerpconnect/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def _add_shipping_line(self, map_record, values):

if values.get('carrier_id'):
carrier = self.env['delivery.carrier'].browse(values['carrier_id'])
line_builder.product_id = carrier.product_id
line_builder.product = carrier.product_id

line = (0, 0, line_builder.get_line())
values['order_line'].append(line)
Expand Down
27 changes: 27 additions & 0 deletions magentoerpconnect/tests/test_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,30 @@ def test_import_guest_order(self):
partner_binding = binding.partner_id.magento_bind_ids
self.assertEqual(partner_binding.magento_id, 'guestorder:900000700')
self.assertTrue(partner_binding.guest_customer)

def test_import_carrier_product(self):
""" Product of a carrier is used in the sale line """
product = self.env['product.product'].create({
'name': 'Carrier Product',
})
self.env['delivery.carrier'].create({
'name': 'Flatrate',
'partner_id': self.env.ref('base.main_partner').id,
'product_id': product.id,
'magento_code': 'flatrate_flatrate',
'magento_carrier_code': 'flatrate_flatrate',
})
binding = self._import_sale_order(900000691)
# check if we have a line with the carrier product,
# which is the shipping line
shipping_line = False
for line in binding.order_line:
if line.product_id == product:
shipping_line = True
self.assertTrue(shipping_line,
msg='No shipping line with the product of the carrier '
'has been found. Line names: %s' %
(', '.join("%s (%s)" % (line.name,
line.product_id.name)
for line
in binding.order_line),))