Welcome to Tryton Prestashop Integration’s documentation!

Contents:

Installing trytond-prestashop module

The steps below below describe the process of installing the module on a tryton instance.

Installation of dependencies

This module depends on a python module called pystashop. Pystashop is installed automatically while installing trytond-prestashop. It can also installed separately by running:

pip install pystashop

Installation from source code

  1. The module source is available online and can be downloaded from here.

  2. The module can be downloaded as a zip or can be cloned by running

    git clone https://github.com/openlabs/trytond-prestashop.git
    
  3. If the module is downloaded as a zip, extract the module which will give a directory.

  4. From the module directory, use the setup.py script with the command:

    python setup.py install
    
  5. The command above makes the module available for use by tryton server instance in a database.

  6. The module can be installed in a tryton database by following to menu:

    Administration > Modules > Modules
  7. This should show the modules list screen as below:

    _images/modules.png
  8. Install the module as shown below:

    Step 1
    _images/install.png
    Step 2
    _images/perform.png
    Step 3
    _images/popup.png

Installation from PYPI

  1. The module can simply be installed by running the command:

    pip install trytond-prestashop
    
  2. The above command will install the latest available and released version of the module. To install the module for a specific version of tryton, run the following commands:

    pip install "trytond-prestashop==`<version>`"
    
    pip install "trytond-prestashop>=`<lower version>`,<`<higher version>`"
    

Configure Prestashop account

Configuring Prestashop settings

The module should be configured with the URL of the Prestashop instance. A web services authentication key should also be provided.

Configure Prestashop account

Create Webservices Key

The web services key can be obtained/created from the prestashop admin panel.

  1. Login to the admin panel

    _images/prestashop-admin.png
  2. Go to webservices configuration via Advanced parameters

    _images/webservices-menu.png
  3. A new key can be generated as shown below:

    Step 1
    _images/add-new-key.png
    Step 2
    _images/create-new-key.png

Tip

Generate a random key for better security, instead of typing a key by yourself.

  1. Make sure you set the required permissions for this key to access appropriate records.

Configure Settings in Tryton

Menu: Sale > Configuration > Prestashop Sites
_images/tryton-new-site.png

Tip

Click Test Connection button to make sure the url and key entered are correct and are able to access the prestashop instance.

Configuring Languages and Order States

Before proceeding with the import and export of orders, the languages and order states must be mapped.

  1. Click the Import Languages button to import all languages from prestashop to tryton. The system will try to intelligently match the languages on Tryton with the languages imported. Although it can always be configured as per the needs of the user.

Note

Prestashop stores language codes in two formats, i.e., ISO 639‑1 2 character codes and IETF language tags where the ISO 639‑1 2 character code can be combined with the ISO 3166-1 country 2 character code via hyphen(-). The default language codes used by prestashop does not seem to adhere to any of the above though. We take into consideration the IETF language tags based codes from prestashop and match with tryton.

In short, the Language Code field on language settings for each language should have the value in the form <2 character ISO Code>-<2 character ISO country code>. For example, United States English becomes en-US and Great Britain English becomes en-GB. Similarly, French from France becomes fr-FR and Portuguese from Brazil becomes pt-BR

  1. Click the Import Order States button to import all order states from prestashop to tryton. The system will map some of the default states with a predefined logic as explained below. Although it can always be configured as per the needs of the user.
Prestashop State(s) Tryton State
Shipped / Delivered Shipment Sent
Canceled Sale Canceled
Payment accepted / Payment remotely accepted / Preparation in progress / Sale Processing
Any other state Sale Confirmed

Understanding the Tryton States

  1. Shipment Sent: The sale in tryton will have a shipment created which will be completely processed and marked as sent.
  2. Sale Canceled: Sale is canceled and cannot be processed further.
  3. Sale Processing: The sale will have a shipment and an invoice but both will be left open for the user to process.
  4. Sale Confirmed: Sale is in confirmed state with no shipment and invoice associated.

Note

The Order States can only be imported only after languages are imported.

Tip

Last order import time indicates the last time at which the orders were last imported from Prestashop to Tryton.

Tip

Last order export time indicates the last time at which the orders were last exported from Tryton to Prestashop.

Cron for importing orders from Prestashop

Learn how to access and deal with crons.

There are two crons from managing import/export from/to prestashop.

_images/crons.png
Name Function
Import Prestashop Orders Periodically imports orders from prestashop and creates sale orders in Tryton.
Export Prestashop Orders’ Status Periodically exports status for sales which were imported by the first cron.

Tip

You need not change the time here to make a quick manual import. You could go back into configuration and click on the Import button instead. Same concept applies for export as well.

Tip

If the time of import/export just does not seem right to you, check your timezone in the preferences. Tryton displays times in the timezone set in the preferences of the user.

Dealing with Tryton Crons

Accessing Crons

Menu: Administration > Scheduler > Scheduled Actions
_images/crons.png

The following fields in a Cron decide when the cron runs and these can be modified as per your need.

_images/cron.png
  • Interval Number and Interval Unit: These fields together make up the interval duration of this cron. By default, it is set to 1 Day. This means that the cron runs once in a day. You could increase or decrease the frequency by changing Interval Number, Interval Unit.
  • Next Call: Indicates the date and time in which the cron will run the next time. You could change this time if you want to prepone or delay the execution of cron.

How it works

This section explains how the import and export of orders between Tryton and Prestashop works.

Note

All the data represented below is demo data and is only for demonstration purposes.

Orders are imported as Sales

Orders placed in Prestashop are imported in Tryton. This is periodically done by the Tryton CRON system. The default interval between two imports is a day, but the interval can be modified to your requirements.

An order in prestashop has a number of entities related and they are imported in tryton as described below:

  • The Order is imported as a Sale. The sale in tryton can be identified by the reference which will be same as the order reference in prestashop. Internally the matching is done using the ID of the order as returned by prestashop.
  • The Customer who placed the order is imported as Party. If the customer already exists in Tryton, then the same customer(party) is linked with the order.
  • The invoice and shipping addresses specified by the customer while placing the order are imported as addresses, and assigned to the sale order’s billing and shipment addresses. If these addresses exist in Tryton, then the same addresses are used else new address(es) for the Party is(are) created.
  • The product lines, i.e., the products bought in the order by the customer are imported as Sale lines. The product in each of these lines is created as product in tryton, if it does not already exist.
  • Discount on order is imported as a sale line in tryton with negative value.
  • Shipping is imported as a sale line in tryton with the price as the shipping value on order in prestashop.
  • Taxes are imported as taxes in tryton with the same details as on prestashop and then are linked to the tax lines on the product [TODO]
  • The state of an order from prestashop to tryton is imported as:
    • If the order in prestashop is paid and shipped, it will be imported in tryton as a done order with all the processes already done. To achieve this, the order’s invoicing method and shipping method are set to manual and no invoice or shipment is created.
    • If the order in prestashop is paid but not shipped, it will be imported in tryton as processing with invoicing being done but not shipped.
    • If the order in prestashop is neither paid nor shipped, it will be imported as confirmed with no invoice and no shipment.

Note

When the order import happens next time, the status of the orders in processing and confirmed state in tryton in tryton will be updated if there is a change in state on Prestashop. [TODO]

Orders in Prestashop

_images/orders-in-ps.png

Orders imported as Sales in Tryton

Menu: Sales > Sales
_images/orders-in-tryton.png

Order View in Prestashop

_images/order-in-ps.png

Sale in Tryton

_images/order-in-tryton.png

This import will also create/update parties and products corresponding to customer and products in the order on prestashop.

Customer in Prestashop

_images/customer-in-ps.png

Party in Tryton

_images/party-in-tryton.png

Product in Prestashop

_images/product-in-ps.png

Product in Tryton

_images/product-in-tryton.png

Exporting Order Status from Tryton to Prestashop

Once the order is processed in Tryton, the shipping status of the order based on delivery and picking is updated on prestashop. This is periodically done by the Tryton CRON system. The default interval between two exports is a day, but can be modified to your requirements.

  • The status of orders which are imported as processing in Tryton will be exported to Prestashop as Delivered once they are marked shipped and done in Tryton.
  • The status of orders which are imported as confirmed in Tryton will be exported to prestashop as Payment accepted when they are invoiced and paid in tryton. These will be also be marked as Delivered if they are marked shipped in Tryton.

Order processed in Tryton

_images/order-processed-in-tryton.png

Order Status exported to Prestashop

_images/order-status-in-ps.png

Indices and tables