WooCommerce connector for Tryton

As discussed on Minimal e-shop for Tryton it makes sense to have a web frontend for selling Tryton. II think it makes sense to be able to have some connectors for people that already have a webshop and they want to sync it with Tryton. I think we should develop one for WooCommerce, as it’s been widely used nowadays. This connector will reuse the the web_shop module from the minimal webshopt but create a new module (web_shop_woocommerce) to sync data with woocommerce.

The WooCommerce REST API can be used to retrieve and push data to WooCommerce. There is an available Python Wrapper for it, so It makes sense to us it.

Using this wrapper we can create the following cron jobs:

  • Export products data to WooCommerce
  • Sync products stock with WooCommerce
  • Import Customer Orders from WooCommerce: Download customer orders and it’s related data from woocommerce to Tryton.

There are several order states on WooCommerce so once the order progress on Tryton, we should upate the states back to woocoomerce so the customer knows that he’s order has been updated.

  • Pending Payment and On-Hold orders should be on Tryton’s Quotation
  • Processing order should be on Tryton’s Processing state.
  • Once the shipment is sent, the order should be in *Completed" woocommerce state.

I think this should be the default behaviour of Tryton but It should be configurable per Tryton shop. So I propose to store the WooCommerce state field on the Sale and allow the developer to customize the state. A task in the queue should be responsible to sync the WooCommerce state with the webshop.


I think this part should be very configurable because for example some will manage stock in WooCommerce, others not etc.

I do not think it is needed to have a order stats synchronization. We can only create completed order in Tryton and deal with the refund state.

I do not think WooCommerce order workflow is really configurable.

But the biggest difficulties are the taxes, the party two-way synchronization and the stock management.

I already did such development for a customer and the WooCommerce API is not really good for synchronization. You mainly have to loop over all records. Or you can store the last sync ID and loop until reaching this ID.

1 Like

I do not think we need to do two-way party sincronization. For me we can try to find existing parties by it’s tax_identifier or email.

Then the parties can be merged back using the merge wizard.

If somebody is interested on it we published an implementation of the woocomerce connector:

This is not perfect but it is used for one of our customers to sync 23k of products and download the woocommerce orders.

Feel free to review, test and leave any comment on it :hugs:


Hey, great you came that far so quickly! - I’d be very happy to test it under “real” conditions - could there be minimal advice how to install and use it?

My destruction potential of guessing is high…


You just need to download the module and activate it on a database.

If you are using docker, you can create a Dockerfile with the following content:

FROM tryton/tryton:$SERIES as builder
USER root
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        git \
    && rm -rf /var/lib/apt/lists/*
RUN git clone https://gitlab.com/kopen/web_shop_woocommerce \
    && cd web_shop_woocommerce \
    && python3 setup.py sdist

FROM tryton/tryton:$SERIES
USER root
COPY --from=builder /web_shop_woocommerce/dist /dist
RUN pip3 install --no-cache-dir --install-option="-O1" \
        /dist/* \
    && rm -rf /root/.cache /dist/
USER trytond

Please update $SERIES with the series you are running from.

Then you can run this with:

docker build . -t trytond_woocommerce
docker run trytond_woocommerce


With kind help of @edbo, I could manage to install it in a PIP installation:

cd <your_environment>
. bin/activate
## the module depends on another module called web_shop. Install that one first.

git clone https://gitlab.com/kopen/web_shop
cd web_shop
python3 setup.py install
cd ..
git clone https://gitlab.com/kopen/web_shop_woocommerce
cd web_shop_woocommerce
python3 setup.py install
cd ..
trytond-admin -c [your-trytond.conf] -d [your database] -m -vv
trytond-admin -c trytond.conf -d [your database] --update=web_shop_woocommerce --activate-dependencies -vv

(Hope I copied everything correctly).

I only succeeded to install it with tryton 5.6, not 5.4.
Now I can see the web shop items at “sales” menu entry, created a woocommerce web shop and pasted the woocommerce keys (credentials).

Now nothing happens, and I couldn’t find any “action” buttons or so. @pokoli mentioned cron jobs above - in my install none such are running. Is my guess true that I need a certain cron job - and how would I install that in PIP?

Thank you for your work !


It seems the module adds two jobs.

  • Update WooCommerce Products
  • Download WooCommerce Orders

Login as admin into Tryton and go to “Administration” -> “Scheduler” -> “Schedules Actions”

Create a new action and select one of the above jobs as “Method”. You can also set when it should run at what time. Use the “Run Once” button to run the job manually (the job is executed directly).

trytond-cron is a standalone process which continuously check all the actions and when the time of that actions is passed the Method will be executed in the background. So when you are testing, it doesn’t make sense a lot to automatically get the data out of woocommerce.

Also trytond-cron comes with the standard Trytond package so you have it already available. To execute it:

  • open a new terminal (commandline)
  • go to your virtual environment
  • activate it
  • trytond-cron -c trytond.conf -d <your database>

You don’t see any output until something will be executed (the time of an action has passed)
In you other terminal you can run the “normal” trytond, connect to it with the client and do everything you want.

Yes, there are two cron jobs to perform the sincronitzation.

The first syncs the webshop products and it’s stock quantity to the woocommerce shop.
The latter downloads customer orders into the sales model. It also creates the customer data into the party model if the customer does not exist already in Tryton.

Thank you very much. I found the “scheduled actions” things already in place. So first attempt was to download orders once manually.

Bildschirmfoto von 2020-09-26 20-16-57

There are open (untouched) orders available in woocommerce, credentials are in place - I guess I should have a look into a logfile… True? Where would I find it?

You should try to understand the error message which is in German and I do not understand.

It depends on how are your running the server and which logging configuration you set.

The message says: “I’m sorry, ressources cannot be listed”

I tried to set up standard logging following the info given here:
https://discuss.tryton.org/t/2311/2, with the standard log-conf.

When I click the “execute once” button from “scheduled actions”, I get this on terminal (and as well in the log file):

Thu Oct 01 17:57:21 2020] INFO:trytond.protocols.dispatcher:<class 'trytond.pool.company.company'>.read(*([1], ['party', 'party.rec_name', 'rec_name', '_timestamp'], {'client': 'f2cd8973-81bb-44b1-b441-b65c2a348310', 'warehouse': None, 'employee': None, 'company': 1, 'company.rec_name': '[here-was-my-company-name]', 'language': 'de', 'language_direction': 'ltr', 'groups': [5, 6, 1, 4, 8, 22, 2, 23, 3, 12, 13, 7, 20, 21, 15, 14, 18, 16, 17, 10, 9, 11, 19], 'locale': {'date': '%d.%m.%Y', 'grouping': [3, 3, 0], 'decimal_point': ',', 'thousands_sep': '.'}, 'company_work_time': {'h': 3600, 'm': 60, 's': 1, 'Y': 6912000.0, 'M': 576000.0, 'w': 144000.0, 'd': 28800.0}}), **{}) from admin@
Thu Oct 01 17:57:21 2020] INFO:werkzeug: - - [01/Oct/2020 17:57:21] "POST /tryton-56/ HTTP/1.1" 200 -
Thu Oct 01 17:57:31 2020] INFO:trytond.protocols.dispatcher:<class 'trytond.pool.ir.cron'>.run_once(*([4], {'client': 'f2cd8973-81bb-44b1-b441-b65c2a348310', 'warehouse': None, 'employee': None, 'company': 1, 'company.rec_name': '[here-was-my-company-name]', 'language': 'de', 'language_direction': 'ltr', 'groups': [5, 6, 1, 4, 8, 22, 2, 23, 3, 12, 13, 7, 20, 21, 15, 14, 18, 16, 17, 10, 9, 11, 19], 'locale': {'date': '%d.%m.%Y', 'grouping': [3, 3, 0], 'decimal_point': ',', 'thousands_sep': '.'}, 'company_work_time': {'h': 3600, 'm': 60, 's': 1, 'Y': 6912000.0, 'M': 576000.0, 'w': 144000.0, 'd': 28800.0}, '_timestamp': {'ir.cron,4': '1601050672.168693'}}), **{}) from admin@
Thu Oct 01 17:57:35 2020] INFO:werkzeug: - - [01/Oct/2020 17:57:35] "POST /tryton-56/ HTTP/1.1" 200 -

I replaced my company name manually.
Hope that speaks… (-;


This seems like an error message from woocommerce as the connector will print the API error in case of any.

So it seems that you have something that is not porperly setup on woocomerce side.

Did you enable url rewriting? IIRC the api won’t work when disabled.

Sorry but there is no error message on the logs you posted. This is because it’s a expected error so it is shown to the user.

Not entirely sure about this, but in the .htaccess of the page the rewrite engine is set to “on”. Is that what you mean - or how would I know? -

I’m using packlink.com API without any trouble.

I tried to dig a little deeper into that. It looks as if I could test my web shop’s API with these URLs simply at the web browser:


When I do so with my credentials, I actually get readable lists, containing my products and orders. So the web shop seems to deliver data.

What could be the problem that my tryton cannot read it? - I’m using a PIP setup in a virtual environment, everything is running locally. Do I need to grant web access manually - or such?


I think your prolbem is that you are using an old version of the API (v2) while the module has been developed on verison v3.

I tried to call


and I get the same answer, so I guess the v3 API is active as well.

Will somebody be so kind and give me a hint how I can proceed?

Well, the connector is using the woocommerce Python library https://pypi.org/project/WooCommerce/ When you read the documentation there you can try those things in your virtual environment. When you get data back, you have ruled out a problem between your woocommerce and the python library. Then it’s time to move into the code of the module.

:rofl: :rofl: :rofl:

Nice to hear what grade of confidence you have about my abilities…
Next life. Maybe…

But I’ll be happy to try and report back anything I’m advised.
(Exepct sudo rm -rf *).