diff --git a/connector_magento/components/__init__.py b/connector_magento/components/__init__.py
index f036ef4ec..04c57ec7f 100644
--- a/connector_magento/components/__init__.py
+++ b/connector_magento/components/__init__.py
@@ -7,3 +7,4 @@
from . import exporter
from . import mapper
from . import deleter
+from . import line_builder
diff --git a/connector_magento/components/line_builder.py b/connector_magento/components/line_builder.py
new file mode 100644
index 000000000..3c2963aeb
--- /dev/null
+++ b/connector_magento/components/line_builder.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+# © 2017 Hibou Corp.
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+
+"""
+
+Line Builders for Magento psudo-payment methods (Store Credit, Rewards...).
+
+"""
+
+from odoo.addons.component.core import Component
+
+
+class StoreCreditLineBuilder(Component):
+ """ Return values for a Store Credit line """
+
+ _name = 'magento.order.line.builder.store_credit'
+ _inherit = 'ecommerce.order.line.builder'
+ _usage = 'order.line.builder.magento.store_credit'
+
+ def __init__(self, work_context):
+ super(StoreCreditLineBuilder, self).__init__(work_context)
+ self.product_ref = ('connector_magento',
+ 'product_product_store_credit')
+ self.sign = -1
+ self.sequence = 991
+
+
+class RewardsLineBuilder(Component):
+ """ Return values for a Rewards line """
+
+ _name = 'magento.order.line.builder.rewards'
+ _inherit = 'ecommerce.order.line.builder'
+ _usage = 'order.line.builder.magento.rewards'
+
+ def __init__(self, work_context):
+ super(RewardsLineBuilder, self).__init__(work_context)
+ self.product_ref = ('connector_magento',
+ 'product_product_rewards')
+ self.sign = -1
+ self.sequence = 992
diff --git a/connector_magento/data/connector_magento_data.xml b/connector_magento/data/connector_magento_data.xml
index 65ae54d58..dc35b11b7 100644
--- a/connector_magento/data/connector_magento_data.xml
+++ b/connector_magento/data/connector_magento_data.xml
@@ -118,5 +118,23 @@ if sale.magento_bind_ids and abs(sale.amount_tax - sale.magento_bind_ids[0].tota
+
+ MAGENTO STORE CREDIT
+ 0.0
+ 0.0
+ service
+ Magento Store Credit
+
+
+
+
+ MAGENTO REWARDS
+ 0.0
+ 0.0
+ service
+ Magento Rewards
+
+
+
diff --git a/connector_magento/models/sale_order/importer.py b/connector_magento/models/sale_order/importer.py
index 8d6918a58..0225a2b7e 100644
--- a/connector_magento/models/sale_order/importer.py
+++ b/connector_magento/models/sale_order/importer.py
@@ -213,12 +213,40 @@ def _add_gift_cards_line(self, map_record, values):
values['order_line'].append(line)
return values
+ def _add_store_credit_line(self, map_record, values):
+ record = map_record.source
+ if not record.get('customer_balance_amount'):
+ return values
+ amount = float(record['customer_balance_amount'])
+ if amount == 0.0:
+ return values
+ line_builder = self.component(usage='order.line.builder.magento.store_credit')
+ line_builder.price_unit = amount
+ line = (0, 0, line_builder.get_line())
+ values['order_line'].append(line)
+ return values
+
+ def _add_rewards_line(self, map_record, values):
+ record = map_record.source
+ if not record.get('reward_currency_amount'):
+ return values
+ amount = float(record['reward_currency_amount'])
+ if amount == 0.0:
+ return values
+ line_builder = self.component(usage='order.line.builder.magento.rewards')
+ line_builder.price_unit = amount
+ line = (0, 0, line_builder.get_line())
+ values['order_line'].append(line)
+ return values
+
def finalize(self, map_record, values):
values.setdefault('order_line', [])
values = self._add_shipping_line(map_record, values)
values = self._add_cash_on_delivery_line(map_record, values)
values = self._add_gift_certificate_line(map_record, values)
values = self._add_gift_cards_line(map_record, values)
+ values = self._add_store_credit_line(map_record, values)
+ values = self._add_rewards_line(map_record, values)
values.update({
'partner_id': self.options.partner_id,
'partner_invoice_id': self.options.partner_invoice_id,
diff --git a/connector_magento/models/stock_picking/common.py b/connector_magento/models/stock_picking/common.py
index e662fa7b0..eb520c5c1 100644
--- a/connector_magento/models/stock_picking/common.py
+++ b/connector_magento/models/stock_picking/common.py
@@ -145,6 +145,9 @@ def on_tracking_number_added(self, record):
# executed after the picking creation
binding.with_delay(priority=20).export_tracking_number()
+ def on_picking_dropship_done(self, record, picking_method):
+ return self.on_picking_out_done(record, picking_method)
+
def on_picking_out_done(self, record, picking_method):
"""
Create a ``magento.stock.picking`` record. This record will then