39
BASE EXTERNAL REFERENTIAL HOW TO CONNECT OPENERP WITH EXTERNAL SYSTEMS OpenERP Community days April 12 th , 2012 Sébastien Beau [email protected] Consultant at Akretion

openERP- How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

  • Upload
    odoo

  • View
    9.738

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

BASE EXTERNAL REFERENTIALHOW TO CONNECT OPENERP

WITH EXTERNAL SYSTEMS

OpenERP Community daysApril 12th, 2012

Sébastien [email protected] at Akretion

Page 2: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Context● June 2009 : Akretion and OpenLabs start a new project

« MagentoERPconnect », the new connector for Magento and OpenERP.

● June 2011 : MagentoERPconnect project is now maintained by the group « MagentoERPconnect Core Editor » composed of Akretion, Camptocamp, OpenLabs and ZikzakMedia.

● February 2012 : Camptocamp and Akretion release a new connector for Prestashop : PrestashopERPconnect

● March 2012 : Akretion release File Exchange, a new way to synchronise automatically files with OpenERP

● Soon : AmazonERPconnect

Page 3: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Goals in 2009Example connection with Magento

● What is needed by my customer :● Must be multi-referential● Must be flexible● Must report errors of synchronisation● Must synchronise all of the data (product, sale

order, picking, invoice, ...)● Must be cheaper

=> These are generic needs !!

Page 4: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Generic needs

MagentoERPconnect

Product m2m

Category

Product Images

Olbs

Base Sale Multichannels

Base External Referentials

MagentoERPconnectBundle Product

MagentoERPconnectProduct Variant

Product Variant Multi

Sale Bundle Product

generic part of the project

Specific partto magento

Product links

Page 5: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Must be multi-referential

● Connecting one Magento is great, but it's better to connect to various Magentos at the same time

=> do not add a new column on each object to store external_id

=> using the table « ir_model_data » to store external ids

Page 6: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Must be flexible ;)

● The mapping (link between OpenERP field and Magento field) should not be hard-coded !

Page 7: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Must be flexible ;)

● Base_external_referential => the magic box

MAPPING1.5.0.0 +

MAPPING1.3.2.4 +

DATA DATA

Page 8: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Must be flexible ;)

● Next step : add generic mapping

MAPPING1.5.0.0 +

MAPPING1.3.2.4 +

DATA DATA

GENERICMAPPING

Page 9: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

How does a mappinglook like?

Page 10: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

How does a mappinglook like?

Page 11: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

3 kinds of mapping lines

● 1. Direct mapping :

Map an OpenERP field with an external field

Page 12: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

3 kinds of mapping lines

● 2. Function mapping :

Use some lines of Python to evaluate a field

Page 13: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

3 kinds of mapping lines

● 3. Submapping : a field will be evaluated using another mapping object

Example : the field “order_line” of the “sale_order” will be evaluated by the mapping of the “order_ line”

Page 14: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

More information about sub-mapping

_transform_external_resources

for each line

_transform_one__resource

_get_mapping if not exist

merge_with_default_value

_transform_sub_mapping

_transform_one_resource

code to convert data

code to merge converted data with default value

merge_with_default_value

for each submapping

_transform_sub_mapping

_transform_resources

ONE SALE ORDER

Page 15: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

How can I make my own mapping?

● Step 1 : Add mapping in OpenERP with the interface and test it

● Step 2 : Export it and put it in a module● Step 3 : Take a drink... you're done, and your

boss can not imagine that you have already finished ;)

Page 16: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Error management

Before :● If a synchronisation failed, everything had to be

restarted from the beginning. No incremental import.

● No easy way to understand what happened, what raised an error, what worked

● Bugs can not be reproduced and fixed easily

Page 17: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Error management NOW

RAPPORT

DATA DATA

MAPPING1.5.0.0 +

MAPPING1.3.2.4 +

Soon : email notification ;)

Page 18: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Error management NOW

● Incremental import / export => resources are exported one by one. After importing / exporting a resource, everything is committed

Synchronize orders

import one order and commit it

import one order and commit it

import one order and commit it

Page 19: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Error management NOW

A report is generated for each synchronisation

Page 20: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Error management NOW

● For each failure, a report line is generated and can be replayed easily

Page 21: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Base external is great but...

E-commerce needs more than a generic module of synchronisation. We also need to :● Import orders● Play on_change on order lines and sale orders● Play workflow● Compute or use external taxes● Export products, stock levels, ...

Page 22: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Base_sale_multichannels● An abstract module to make OpenERP a

MULTI-SALE-CHANNELS software

Page 23: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Base_sale_multichannels

Page 24: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Base_sale_multichannelsOpenERP

E-Commerce

56971236

56971236

sale order waiting for approval validation

sale order validated

+shipping

confirmed

e-mail with invoice

invoice created

automatically and

confirmed

Payment by check

send

Page 25: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Base_sale_multichannels

Payment configuration

Page 26: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Generic is great buthow does it work ?

● If two modules like MagentoERPconnect and PrestashopERPconnect are installed and overwrite the method “import_orders”, how can it work ?

Button : import_order

import_order (from Magento) import_order (from PrestaShop)

????????

Page 27: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Generic is great, but how does it work ?

● We have to test where we are :(

Page 28: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Decorators are great ;)

Page 29: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Last improvement of the week

● Synchronizing data with Magento is long, very very very very very long !

=> we have to optimize the data sent to Magento

Page 30: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Last improvement of the week

● Before :

When we send a resource (product, category...) in multi-lang, we send x time all fields of a resource => sending X time a not translatable product is useless

● Now :

Base_external_referentials generates a dictionary with all resource information :

{'en_US': {all of data}, 'fr_FR': {only translatable field}, ...}

Page 31: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Last improvement of the week● Before :

If one field changes on a resource, all fields of the resource are synchronised again

● Now :

Ability to create a group of fields that will have their own “last update date”

Page 32: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Modules that use base_external_referentials

and base_sale_multichannels

● MagentoERPconnect● PrestashopERPconnect● File Exchange● AmazonERPconnect

Page 33: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

MagentoERPconnect'sroadmap

● For May:● Huge re-factoring is coming● RMA synchronisation● Invoice export● Delivery time synchronisation

Page 34: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

PrestashopERPconnect'sroadmap

DONE in 4.5 days:● shop/websites import● customer import● languages & country synchronisation● product import● order import (still missing taxes and shipping costs)

TODO :● finish order import● stock level export● product export ● invoice export (PDF report)● picking export

Page 35: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

File_exchangeWhat is it ?

A new way to synchronize data with file system

STEP 1 : create mapping

Page 36: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

File_exchangeWhat is it?

STEP 2 : build your model file●

Page 37: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

AmazonERPconnect

Will be released in May 2012● Sale order import● Bank statement import

TODO :● stock level export● product export● picking export

Page 38: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Project hosted on launchpad

● https://launchpad.net/openobject-extension● https://launchpad.net/e-commerce-addons● https://launchpad.net/prestashoperpconnect● https://launchpad.net/magentoerpconnect

Modules in extra-addons are deprecated and will be remove soon. Use the specific branches.

Page 39: openERP-  How to connect OpenERP with external Systems, AkretionAkretion base external_referentials_openerpdays

Thank you for your attention

twitter : seb_beau