Skip to content

Commit

Permalink
[MIG] connector_magento to v11
Browse files Browse the repository at this point in the history
  • Loading branch information
hugosantosred committed Apr 9, 2019
1 parent 8145a35 commit 832510b
Show file tree
Hide file tree
Showing 33 changed files with 253 additions and 167 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ install:
- travis_install_nightly
- pip install magento
- pip install beautifulsoup4
- pip install sphinx sphinx_bootstrap_theme sphinx-intl odoo-sphinx-autodoc
- pip install sphinx sphinx_bootstrap_theme sphinx-intl
- pip install -e git+https://github.com/OCA/odoo-sphinx-autodoc.git#egg=odoo-sphinx-autodoc
- printf '[options]\n\nrunning_env = dev' > ${HOME}/.openerp_serverrc

script:
Expand Down
7 changes: 7 additions & 0 deletions .travis_build_doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

cd ${TRAVIS_BUILD_DIR}

sphinx-build -b html ./connector_magento/doc/ ${HOME}/doc
# sphinx-intl build
# sphinx-build -D language=fr -b html ./connector_magento/doc/ ${HOME}/doc/fr
25 changes: 25 additions & 0 deletions .travis_push_doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -o errexit -o nounset

if [ $TRAVIS_BRANCH = "11.0" ] && [ $TRAVIS_PULL_REQUEST = false ]; then
cd ${TRAVIS_BUILD_DIR}
rev=$(git rev-parse --short HEAD)

cd ${HOME}/doc
git init
git config user.name "Guewen Baconnier"
git config user.email "[email protected]"
git remote add upstream https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git
git fetch upstream
git reset upstream/gh-pages

echo "odoo-magento-connector.com" > CNAME
touch .nojekyll

touch .
git add -A .
git commit -m"rebuild pages at ${rev}"

git push -q upstream HEAD:gh-pages
fi
2 changes: 1 addition & 1 deletion connector_magento/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Magento Connector

This is the new release of the Open-Source connector linking Odoo and
Magento also known under the name of **Magentoerpconnect**. It is
build on top of the `connector`_ framework. It is is structured so that
build on top of the `connector`_ framework. It is structured so that
it can be extended or modified easily from separate addons, a factor of
success when the implementations of Magento vary a lot.

Expand Down
2 changes: 1 addition & 1 deletion connector_magento/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{'name': 'Magento Connector',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Connector',
'depends': ['account',
'base_technical_user',
Expand Down
6 changes: 3 additions & 3 deletions connector_magento/components/backend_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import socket
import logging
import xmlrpclib
import xmlrpc.client

from odoo.addons.component.core import AbstractComponent
from odoo.addons.queue_job.exception import RetryableJobError
Expand Down Expand Up @@ -90,7 +90,7 @@ def call(self, method, arguments):
start = datetime.now()
try:
result = self.api.call(method, arguments)
except:
except Exception:
_logger.error("api.call('%s', %s) failed", method, arguments)
raise
else:
Expand All @@ -104,7 +104,7 @@ def call(self, method, arguments):
raise NetworkRetryableError(
'A network error caused the failure of the job: '
'%s' % err)
except xmlrpclib.ProtocolError as err:
except xmlrpc.client.ProtocolError as err:
if err.errcode in [502, # Bad gateway
503, # Service unavailable
504]: # Gateway timeout
Expand Down
6 changes: 3 additions & 3 deletions connector_magento/components/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def run(self, external_id, binding, mapper=None):

# find the translatable fields of the model
fields = self.model.fields_get()
translatable_fields = [field for field, attrs in fields.iteritems()
translatable_fields = [field for field, attrs in list(fields.items())
if attrs.get('translate')]

if mapper is None:
Expand All @@ -316,9 +316,9 @@ def run(self, external_id, binding, mapper=None):
for storeview in lang_storeviews:
lang_record = self._get_magento_data(storeview.external_id)
map_record = mapper.map_record(lang_record)
record = map_record.values()
record = list(map_record.values())

data = dict((field, value) for field, value in record.iteritems()
data = dict((field, value) for field, value in list(record.items())
if field in translatable_fields)

binding.with_context(connector_no_export=True,
Expand Down
38 changes: 19 additions & 19 deletions connector_magento/data/connector_magento_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'magento.backend'" name="model"/>
<field eval="'_scheduler_import_sale_orders'" name="function"/>
<field eval="'()'" name="args"/>
<field ref="connector_magento.model_magento_backend" name="model_id"/>
<field name="state">code</field>
<field name="code">model._scheduler_import_sale_orders()</field>
</record>

<record model="ir.cron" id="ir_cron_import_customer_groups" forcecreate="True">
Expand All @@ -26,9 +26,9 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'magento.backend'" name="model"/>
<field eval="'_scheduler_import_customer_groups'" name="function"/>
<field eval="'()'" name="args"/>
<field ref="connector_magento.model_magento_backend" name="model_id"/>
<field name="state">code</field>
<field name="code">model._scheduler_import_customer_groups()</field>
</record>

<record model="ir.cron" id="ir_cron_import_partners" forcecreate="True">
Expand All @@ -39,9 +39,9 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'magento.backend'" name="model"/>
<field eval="'_scheduler_import_partners'" name="function"/>
<field eval="'()'" name="args"/>
<field ref="connector_magento.model_magento_backend" name="model_id"/>
<field name="state">code</field>
<field name="code">model._scheduler_import_partners()</field>
</record>

<record model="ir.cron" id="ir_cron_import_product_categories" forcecreate="True">
Expand All @@ -52,11 +52,11 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'magento.backend'" name="model"/>
<field eval="'_scheduler_import_product_categories'" name="function"/>
<field eval="'()'" name="args"/>
<field ref="connector_magento.model_magento_backend" name="model_id"/>
<field name="state">code</field>
<field name="code">model._scheduler_import_product_categories()</field>
</record>

<record model="ir.cron" id="ir_cron_import_product_product" forcecreate="True">
<field name="name">Magento - Import Products</field>
<field eval="False" name="active"/>
Expand All @@ -65,9 +65,9 @@
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'magento.backend'" name="model"/>
<field eval="'_scheduler_import_product_product'" name="function"/>
<field eval="'()'" name="args"/>
<field ref="connector_magento.model_magento_backend" name="model_id"/>
<field name="state">code</field>
<field name="code">model._scheduler_import_product_product()</field>
</record>

<record model="ir.cron" id="ir_cron_update_product_stock_qty" forcecreate="True">
Expand All @@ -78,9 +78,9 @@
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall"/>
<field eval="'magento.backend'" name="model"/>
<field eval="'_scheduler_update_product_stock_qty'" name="function"/>
<field eval="'()'" name="args"/>
<field ref="connector_magento.model_magento_backend" name="model_id"/>
<field name="state">code</field>
<field name="code">model._scheduler_update_product_stock_qty()</field>
</record>

<record id="excep_wrong_total_amount" model="exception.rule">
Expand Down
16 changes: 8 additions & 8 deletions connector_magento/doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def add_path(*paths):
master_doc = 'index'

# General information about the project.
project = u'Odoo Magento Connector'
copyright = u'2013-2015, Odoo Community Association (OCA)'
project = 'Odoo Magento Connector'
copyright = '2013-2015, Odoo Community Association (OCA)'

# The version info for the project you're documenting, acts as
# replacement for |version| and |release|, also used in various other
Expand Down Expand Up @@ -320,8 +320,8 @@ def add_path(*paths):
# start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'odoo-magento-connector.tex',
u'Odoo Magento Connector Documentation',
u'Odoo Community Association (OCA)', 'manual'),
'Odoo Magento Connector Documentation',
'Odoo Community Association (OCA)', 'manual'),
]

# The name of an image file (relative to this directory) to place at the
Expand Down Expand Up @@ -351,8 +351,8 @@ def add_path(*paths):
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'odoo-magento-connector',
u'Odoo Magento Connector Documentation',
[u'Odoo Community Association (OCA)'], 1)
'Odoo Magento Connector Documentation',
['Odoo Community Association (OCA)'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -366,8 +366,8 @@ def add_path(*paths):
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Odoo Magento Connector',
u'Odoo Magento Connector Documentation',
u'Odoo Community Association (OCA)', 'Odoo Magento Connector',
'Odoo Magento Connector Documentation',
'Odoo Community Association (OCA)', 'Odoo Magento Connector',
'Connector between Odoo and Magento',
'Miscellaneous'),
]
Expand Down
4 changes: 2 additions & 2 deletions connector_magento/models/account_invoice/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

import logging
import xmlrpclib
import xmlrpc.client
from odoo import api, models, fields
from odoo.addons.component.core import Component
from odoo.addons.queue_job.job import job, related_action
Expand Down Expand Up @@ -70,7 +70,7 @@ class AccountInvoiceAdapter(Component):
def _call(self, method, arguments):
try:
return super(AccountInvoiceAdapter, self)._call(method, arguments)
except xmlrpclib.Fault as err:
except xmlrpc.client.Fault as err:
# this is the error in the Magento API
# when the invoice does not exist
if err.faultCode == 100:
Expand Down
4 changes: 2 additions & 2 deletions connector_magento/models/account_invoice/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging

import xmlrpclib
import xmlrpc.client

from odoo import _
from odoo.addons.component.core import Component
Expand Down Expand Up @@ -70,7 +70,7 @@ def run(self, binding):
external_id = self._export_invoice(magento_order.external_id,
lines_info,
mail_notification)
except xmlrpclib.Fault as err:
except xmlrpc.client.Fault as err:
# When the invoice is already created on Magento, it returns:
# <Fault 102: 'Cannot do invoice for order.'>
# We'll search the Magento invoice ID to store it in Odoo
Expand Down
16 changes: 9 additions & 7 deletions connector_magento/models/magento_backend/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

from datetime import datetime, timedelta
from odoo import models, fields, api, _
from odoo.tools import ustr
from odoo.exceptions import UserError

from odoo.addons.connector.checkpoint import checkpoint
from odoo.addons.connector.models.checkpoint import add_checkpoint
from ...components.backend_adapter import MagentoLocation, MagentoAPI

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -42,6 +43,7 @@ def _get_stock_field_id(self):
limit=1)
return field

name = fields.Char(string='Name', required=True)
version = fields.Selection(selection='select_versions', required=True)
location = fields.Char(
string='Location',
Expand Down Expand Up @@ -213,8 +215,8 @@ def work_on(self, model_name, **kwargs):
def add_checkpoint(self, record):
self.ensure_one()
record.ensure_one()
return checkpoint.add_checkpoint(self.env, record._name, record.id,
self._name, self.id)
return add_checkpoint(self.env, record._name, record.id,
self._name, self.id)

@api.multi
def synchronize_metadata(self):
Expand All @@ -229,11 +231,11 @@ def synchronize_metadata(self):
self.env[model_name].import_batch(backend)
return True
except Exception as e:
_logger.error(e.message, exc_info=True)
_logger.error(ustr(e))
raise UserError(
_(u"Check your configuration, we can't get the data. "
u"Here is the error:\n%s") %
str(e).decode('utf-8', 'ignore'))
_("Check your configuration, we can't get the data. "
"Here is the error:\n%s") %
ustr(e))

@api.multi
def import_partners(self):
Expand Down
4 changes: 2 additions & 2 deletions connector_magento/models/partner/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging
import xmlrpclib
import xmlrpc.client
from odoo import models, fields, api
from odoo.addons.queue_job.job import job
from odoo.addons.component.core import Component
Expand Down Expand Up @@ -153,7 +153,7 @@ class PartnerAdapter(Component):
def _call(self, method, arguments):
try:
return super(PartnerAdapter, self)._call(method, arguments)
except xmlrpclib.Fault as err:
except xmlrpc.client.Fault as err:
# this is the error in the Magento API
# when the customer does not exist
if err.faultCode == 102:
Expand Down
3 changes: 1 addition & 2 deletions connector_magento/models/partner/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ class BaseAddressImportMapper(AbstractComponent):
direct = [('postcode', 'zip'),
('city', 'city'),
('telephone', 'phone'),
('fax', 'fax'),
('company', 'company'),
]

Expand Down Expand Up @@ -284,7 +283,7 @@ def street(self, record):
if len(lines) == 1:
result = {'street': lines[0], 'street2': False}
elif len(lines) >= 2:
result = {'street': lines[0], 'street2': u' - '.join(lines[1:])}
result = {'street': lines[0], 'street2': ' - '.join(lines[1:])}
else:
result = {}
return result
Expand Down
8 changes: 4 additions & 4 deletions connector_magento/models/product/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging
import xmlrpclib
import xmlrpc.client

from collections import defaultdict

Expand All @@ -19,7 +19,7 @@


def chunks(items, length):
for index in xrange(0, len(items), length):
for index in range(0, len(items), length):
yield items[index:index + length]


Expand Down Expand Up @@ -113,7 +113,7 @@ def recompute_magento_qty(self):
for product in self:
backends[product.backend_id].add(product.id)

for backend, product_ids in backends.iteritems():
for backend, product_ids in list(backends.items()):
self._recompute_magento_qty_backend(backend,
self.browse(product_ids))
return True
Expand Down Expand Up @@ -189,7 +189,7 @@ class ProductProductAdapter(Component):
def _call(self, method, arguments):
try:
return super(ProductProductAdapter, self)._call(method, arguments)
except xmlrpclib.Fault as err:
except xmlrpc.client.Fault as err:
# this is the error in the Magento API
# when the product does not exist
if err.faultCode == 101:
Expand Down
Loading

0 comments on commit 832510b

Please sign in to comment.