Skip to content

Commit

Permalink
[MIG] connector_magento_payment_ref: Migration to 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Sep 13, 2017
1 parent 2a457d4 commit efb483d
Show file tree
Hide file tree
Showing 22 changed files with 1,118 additions and 178 deletions.
65 changes: 65 additions & 0 deletions connector_magento_payment_ref/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3


===================================
Connector Magento Payment Reference
===================================

This module let's you define on the payment method the path to a value to use as transaction id into
the informations of a sale order returned as json by magento and map this information into
the transaction_id field defined by OCA/bank-statement-reconcile/base_transaction_id.

The main purpose is to ease the reconciliation process.

Configuration
=============

For each payment method, you can define the path to the transaction_id value in
the informations provided by magento.


Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/107/10.0


Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/connector-magento/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Laurent Mignon <[email protected]>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# -*- coding: utf-8 -*-
from . import models
from . import components
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
Map the payment identifier in your sale order""",
'author': 'ACSONE SA/NV,'
'Odoo Community Association (OCA)',
'website': "http://acsone.eu",
'website': 'https://github.com/OCA/connector-magento',
'category': 'Connector',
'version': '8.0.1.0.0',
'version': '10.0.1.0.0',
'license': 'AGPL-3',
'depends': [
'magentoerpconnect',
'sale_payment_method',
'component',
'connector',
'connector_magento',
'account_payment_mode',
'base_transaction_id',
],
'data': [
'views/payment_method_view.xml',
'views/account_payment_mode.xml',
],
}
2 changes: 2 additions & 0 deletions connector_magento_payment_ref/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import sale_order_import_mapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Copyright 2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo.addons.component.core import Component
from odoo.addons.connector.components.mapper import mapping


class SaleOrderImportMapper(Component):
_inherit = 'magento.sale.order.mapper'

@mapping
def payment(self, record):
vals = super(SaleOrderImportMapper, self).payment(record)
payment_mode_id = vals.get('payment_mode_id')
if payment_mode_id:
payment_mode = self.env['account.payment.mode'].browse(
payment_mode_id)
if payment_mode.transaction_id_path:
value = record
for key in payment_mode.transaction_id_path.split('.'):
value = value.get(key)
if not value:
break
vals['transaction_id'] = value
return vals
2 changes: 2 additions & 0 deletions connector_magento_payment_ref/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import account_payment_mode
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields
from odoo import models, fields


class PaymentMethod(models.Model):
_inherit = 'payment.method'
class AccountPaymentMode(models.Model):
_inherit = 'account.payment.mode'

transaction_id_path = fields.Char(
help=('Path to the value into the informations provided by Magento '
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions connector_magento_payment_ref/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import test_sale_order

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions connector_magento_payment_ref/tests/test_sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from os.path import dirname, join
from odoo.addons.connector_magento.tests.common import MagentoSyncTestCase, \
recorder

CASSETTE_LIBRARY_DIR = join(dirname(__file__), 'fixtures/cassettes')


class TestSaleOrder(MagentoSyncTestCase):
""" Test the imports from a Magento Mock.
"""

def setUp(self):
super(TestSaleOrder, self).setUp()
self.payment_method = self.env['account.payment.mode'].search(
[('name', '=', 'checkmo')],
limit=1,
)

def _import_sale_order(self, increment_id, cassette=True):
return self._import_record('magento.sale.order',
increment_id, cassette=cassette)

def test_transaction_id_mapping(self):
""" Test import of sale order with a payment transaction id"""
self.payment_method.transaction_id_path = 'payment.transaction_id'
with recorder.use_cassette('import_sale_order_transaction_id',
cassette_library_dir=CASSETTE_LIBRARY_DIR):
binding = self._import_sale_order(100000201, cassette=False)
self.assertEqual(binding.transaction_id, '951')

def test_transaction_id_mapping_wrong_path(self):
""" Test import of sale order with a wrong path to the
transaction_id"""
self.payment_method.transaction_id_path = 'payment.trans'
with recorder.use_cassette('import_sale_order_transaction_id',
cassette_library_dir=CASSETTE_LIBRARY_DIR):
binding = self._import_sale_order(100000201, cassette=False)
self.assertEqual(binding.transaction_id, False)
13 changes: 13 additions & 0 deletions connector_magento_payment_ref/views/account_payment_mode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="account_payment_mode_form_view" model="ir.ui.view">
<field name="name">account_payment_mode.form.view (connector_magento_payment_ref)</field>
<field name="model">account.payment.mode</field>
<field name="inherit_id" ref="account_payment_mode.account_payment_mode_form"/>
<field name="arch" type="xml">
<field name="fixed_journal_id" position="after">
<field name="transaction_id_path" placeholder="payment.last_trans_id"/>
</field>
</field>
</record>
</odoo>
57 changes: 0 additions & 57 deletions magentoerpconnect_transaction_id/README.rst

This file was deleted.

3 changes: 0 additions & 3 deletions magentoerpconnect_transaction_id/models/__init__.py

This file was deleted.

26 changes: 0 additions & 26 deletions magentoerpconnect_transaction_id/models/sale.py

This file was deleted.

2 changes: 0 additions & 2 deletions magentoerpconnect_transaction_id/tests/__init__.py

This file was deleted.

67 changes: 0 additions & 67 deletions magentoerpconnect_transaction_id/tests/test_synchronization.py

This file was deleted.

15 changes: 0 additions & 15 deletions magentoerpconnect_transaction_id/views/payment_method_view.xml

This file was deleted.

1 change: 1 addition & 0 deletions setup/connector_magento_payment_ref/odoo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
6 changes: 6 additions & 0 deletions setup/connector_magento_payment_ref/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit efb483d

Please sign in to comment.