inventree-woocommerce 0.6.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- inventree_woocommerce-0.6.1/LICENSE +21 -0
- inventree_woocommerce-0.6.1/PKG-INFO +455 -0
- inventree_woocommerce-0.6.1/README.md +436 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/__init__.py +1 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/accounts.py +316 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/admin.py +114 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/api.py +530 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/builds.py +131 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/catalog.py +412 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/config.py +170 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/core.py +478 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/events.py +146 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/images.py +118 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/migrations/0001_initial.py +172 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/migrations/0002_accounts_and_builds.py +75 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/migrations/0003_product_permalink.py +20 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/migrations/0004_quotes_and_shipments.py +285 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/migrations/0005_quote_line_charges.py +17 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/migrations/__init__.py +0 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/models.py +298 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/orders.py +561 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/providers.py +122 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/quote_pdf.py +166 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/quotes.py +760 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/report_templates/inventree_woocommerce_quote.html +149 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/shipments.py +137 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/shop_link.py +74 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/static/shop_panels.js +708 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/sync.py +316 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/tasks.py +81 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/version.py +5 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce/woo_client.py +156 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce.egg-info/PKG-INFO +455 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce.egg-info/SOURCES.txt +47 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce.egg-info/dependency_links.txt +1 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce.egg-info/entry_points.txt +2 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce.egg-info/requires.txt +1 -0
- inventree_woocommerce-0.6.1/inventree_woocommerce.egg-info/top_level.txt +1 -0
- inventree_woocommerce-0.6.1/pyproject.toml +53 -0
- inventree_woocommerce-0.6.1/setup.cfg +4 -0
- inventree_woocommerce-0.6.1/tests/test_accounts_builds.py +81 -0
- inventree_woocommerce-0.6.1/tests/test_catalog.py +158 -0
- inventree_woocommerce-0.6.1/tests/test_orders.py +58 -0
- inventree_woocommerce-0.6.1/tests/test_providers.py +103 -0
- inventree_woocommerce-0.6.1/tests/test_quotes.py +112 -0
- inventree_woocommerce-0.6.1/tests/test_shipments.py +26 -0
- inventree_woocommerce-0.6.1/tests/test_sync_send.py +110 -0
- inventree_woocommerce-0.6.1/tests/test_woo_client.py +98 -0
- inventree_woocommerce-0.6.1/tests/test_xero_credit.py +39 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tyler Brannigan / OMG Harness
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: inventree-woocommerce
|
|
3
|
+
Version: 0.6.1
|
|
4
|
+
Summary: InvenTree plugin: run a WooCommerce shop from InvenTree - catalogue, stock, orders, Build Orders, credit accounts, quote requests and shipment updates.
|
|
5
|
+
Author: Tyler Brannigan / OMG Harness
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/SXSLYDA/inventree-woocommerce
|
|
8
|
+
Project-URL: Issues, https://github.com/SXSLYDA/inventree-woocommerce/issues
|
|
9
|
+
Keywords: inventree,inventree-plugin,woocommerce,wordpress,ecommerce,inventory
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Framework :: Django
|
|
12
|
+
Classifier: Framework :: InvenTree
|
|
13
|
+
Classifier: Topic :: Office/Business
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# inventree-woocommerce
|
|
21
|
+
|
|
22
|
+
An [InvenTree](https://inventree.org) plugin that runs a WooCommerce shop from your InvenTree data.
|
|
23
|
+
|
|
24
|
+
- **Publishes parts** you flag (or a whole category) as WooCommerce products: title, SKU, price, description,
|
|
25
|
+
a specification table of chosen parameters, the part image, and **documents** (drawings, datasheets) from the
|
|
26
|
+
part's attachments.
|
|
27
|
+
- **Keeps stock in sync** as it changes. Parts are sold either *from stock only* (no backorders) or
|
|
28
|
+
*built to order* (backorders allowed, with a lead time shown).
|
|
29
|
+
- **Turns paid orders into Sales Orders**: customer, contact, shipping address, line items, shipping and fees,
|
|
30
|
+
with a note back on the WooCommerce order.
|
|
31
|
+
- **Creates Build Orders** for build-to-order items that stock can't cover, linked to the Sales Order.
|
|
32
|
+
- **Quote requests**: logged-in customers ask for prices on as many items as they need, each with layout drawings
|
|
33
|
+
or photos, a sample, or a call to discuss. You price them in InvenTree; they accept all or part of the quote
|
|
34
|
+
online and pay (or charge their account). Needs the companion WordPress plugin.
|
|
35
|
+
- **Shipments back to the customer**: completing a shipment in InvenTree emails "dispatched" / "delivered on"
|
|
36
|
+
(with tracking if any) and completes the WooCommerce order once everything has shipped.
|
|
37
|
+
- **Panels in InvenTree**: Web Shop and Quote Requests dashboard widgets, a Web Shop panel on each salable part (in the shop? if
|
|
38
|
+
not, why not?), and a Web Order panel on Sales Orders that came from the shop.
|
|
39
|
+
- **Credit accounts**: customers you approve in InvenTree can "charge to my account" at checkout (with their PO
|
|
40
|
+
number), within a credit limit, using the companion WordPress plugin in `wordpress/inventree-shop/`.
|
|
41
|
+
Everyone else pays online through any WooCommerce gateway (Stripe, PayPal, ...).
|
|
42
|
+
|
|
43
|
+
InvenTree stays the source of truth. WooCommerce does what it's good at: storefront, cart, checkout, payment,
|
|
44
|
+
tax and shipping.
|
|
45
|
+
|
|
46
|
+
Tested with InvenTree 1.5.8 and 1.6.0 (minimum 1.5.0).
|
|
47
|
+
|
|
48
|
+
## How it decides what's in the shop
|
|
49
|
+
|
|
50
|
+
A part is published when it is **Active** and **Salable**, and either:
|
|
51
|
+
|
|
52
|
+
| Shop parameter (default name `Web Shop`) | Result |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `Yes` / `Stock` | Sold from stock only - WooCommerce won't sell more than you have |
|
|
55
|
+
| `Build` / `Build to order` | Built to order - backorders allowed, lead time from the `Lead Time` parameter, or the *Default lead time* setting (6 weeks) |
|
|
56
|
+
| `No` | Kept out of the shop, even inside the shop category |
|
|
57
|
+
| *(not set)* | Published only if the part is in the **Shop category** (or below it), using the category mode |
|
|
58
|
+
|
|
59
|
+
**Build-to-order assemblies wait for a released design.** You're selling something you haven't built yet, so
|
|
60
|
+
it only goes on sale once its BOM is **validated** in InvenTree (and, if you turn on *Build to order needs a
|
|
61
|
+
locked part*, once the part is **locked**). Edit the BOM later and InvenTree un-validates it, which takes the
|
|
62
|
+
product out of the shop until you validate it again. Parts waiting on this are listed under `awaiting_release`
|
|
63
|
+
in the status endpoint. If the part has a **revision** it's shown on the product page.
|
|
64
|
+
Every build-to-order product also shows the *Build-to-order note* setting, e.g. "Call 08 1234 5678 to discuss
|
|
65
|
+
your requirements."
|
|
66
|
+
|
|
67
|
+
**Documents.** Mark an attachment on the part for the shop by giving it the tag `shop`, or by putting `[shop]`
|
|
68
|
+
in its comment. It's listed under "Documents" on the product page, named after its comment (without the marker)
|
|
69
|
+
or its file name. External link attachments are listed as they are. Uploaded files are served through signed
|
|
70
|
+
links that only work while the attachment is still marked and the part is still in the shop. PDFs and images open
|
|
71
|
+
in the browser; any other file type downloads.
|
|
72
|
+
|
|
73
|
+
A part with no sale price is sent as a **draft**, so nothing is ever sold for $0. The price is the
|
|
74
|
+
lowest-quantity sell price break, converted to the shop currency with InvenTree's exchange rates if needed.
|
|
75
|
+
|
|
76
|
+
**Stock sent to the shop** = in stock − allocated to builds − still to ship on open sales orders − stock reserve.
|
|
77
|
+
Unallocated web orders count straight away, so the shop can't resell units it has just sold.
|
|
78
|
+
|
|
79
|
+
Anything else (another plugin, a script, a person) can control the shop just by setting the shop parameter,
|
|
80
|
+
price and image on a part. This plugin has no dependency on how those get set.
|
|
81
|
+
|
|
82
|
+
## Install
|
|
83
|
+
|
|
84
|
+
One version covers both halves: the InvenTree plugin and the WordPress plugin (`wordpress/inventree-shop`).
|
|
85
|
+
Each [GitHub release](https://github.com/SXSLYDA/inventree-woocommerce/releases) has the WordPress zip.
|
|
86
|
+
|
|
87
|
+
1. **InvenTree, package installer:** install the update script once, then let it install the plugin. It pins
|
|
88
|
+
the plugin to the newest release tag, backs up the database, runs `invoke update`, restarts InvenTree and
|
|
89
|
+
checks the plugin's migrations:
|
|
90
|
+
```bash
|
|
91
|
+
sudo curl -fsSL -o /usr/local/bin/inventree-shop-update \
|
|
92
|
+
https://raw.githubusercontent.com/SXSLYDA/inventree-woocommerce/main/tools/server-update.sh
|
|
93
|
+
sudo chmod +x /usr/local/bin/inventree-shop-update
|
|
94
|
+
sudo inventree-shop-update # newest release; or: sudo inventree-shop-update v0.6.0
|
|
95
|
+
```
|
|
96
|
+
**Docker:** add `inventree-woocommerce @ git+https://github.com/SXSLYDA/inventree-woocommerce.git@vX.Y.Z`
|
|
97
|
+
(the newest release tag) to `plugins.txt` in your data volume, run `invoke update` and restart.
|
|
98
|
+
2. In InvenTree *Admin Center > Plugin Settings*, turn on **Enable URL integration**,
|
|
99
|
+
**Enable event integration**, **Enable schedule integration** and **Enable interface integration**. Then
|
|
100
|
+
activate **WooCommerce Shop**.
|
|
101
|
+
3. Create the plugin's tables. It ships normal Django migrations:
|
|
102
|
+
```
|
|
103
|
+
invoke migrate # or: invoke update
|
|
104
|
+
```
|
|
105
|
+
(Package installer: `inventree run invoke migrate`.) Make sure InvenTree's background worker is running -
|
|
106
|
+
syncs and orders are processed there.
|
|
107
|
+
4. **Website:** upload `inventree-shop-X.Y.Z.zip` from the same release in WordPress > Plugins > Add New >
|
|
108
|
+
Upload Plugin (WooCommerce must be active).
|
|
109
|
+
|
|
110
|
+
**From PyPI:** add `inventree-woocommerce` (or pin a version, e.g. `inventree-woocommerce==0.6.0`) to `plugins.txt`, then run `invoke update` and restart. The WordPress plugin still comes from the GitHub release zip.
|
|
111
|
+
|
|
112
|
+
**Updating later:** `sudo inventree-shop-update --check-only` shows what's installed, pinned and newest;
|
|
113
|
+
`sudo inventree-shop-update` updates to the newest release (or name one). Read the release's notes in
|
|
114
|
+
[CHANGELOG.md](CHANGELOG.md) first - they say when a release adds a migration or changes the WordPress plugin,
|
|
115
|
+
and upload the matching WordPress zip when it does. Rolling back: `sudo inventree-shop-update v0.6.0
|
|
116
|
+
--allow-downgrade` (only between versions with the same migrations, or restore the backup it made).
|
|
117
|
+
|
|
118
|
+
## Connect WooCommerce
|
|
119
|
+
|
|
120
|
+
1. **API key.** In WordPress: *WooCommerce > Settings > Advanced > REST API > Add key*, permission
|
|
121
|
+
**Read/Write**. Copy the consumer key and secret into the plugin settings, along with the **Shop URL**
|
|
122
|
+
(`https://...`). WordPress permalinks must be on (anything except "Plain").
|
|
123
|
+
2. **Webhook.** *WooCommerce > Settings > Advanced > Webhooks > Add webhook*:
|
|
124
|
+
- Status: Active
|
|
125
|
+
- Topic: **Order created**, then add a second identical webhook with topic **Order updated**. The order
|
|
126
|
+
usually becomes paid after it's created, so you need both. Duplicate deliveries are ignored.
|
|
127
|
+
- Delivery URL: `https://<your-inventree>/plugin/woocommerce/webhook/order/`
|
|
128
|
+
- Secret: a long random string - put the same value in the plugin's **Webhook secret**
|
|
129
|
+
3. **Images.** WooCommerce downloads part images from InvenTree through signed links, so InvenTree must be
|
|
130
|
+
reachable from the shop over https. If InvenTree's site URL isn't the public address, set
|
|
131
|
+
**Public InvenTree URL**.
|
|
132
|
+
4. Check the connection (as a staff user):
|
|
133
|
+
```
|
|
134
|
+
POST /plugin/woocommerce/test-connection/
|
|
135
|
+
```
|
|
136
|
+
It reports the WooCommerce version and the store currency. The store currency must match **Shop currency**.
|
|
137
|
+
5. Flag a part with `Web Shop = Yes`, give it a sale price, then run a full sync:
|
|
138
|
+
```
|
|
139
|
+
POST /plugin/woocommerce/sync/ {} (whole shop)
|
|
140
|
+
POST /plugin/woocommerce/sync/ {"part_ids": [12]} (just these parts)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Settings
|
|
144
|
+
|
|
145
|
+
| Setting | What it does |
|
|
146
|
+
|---|---|
|
|
147
|
+
| Shop URL, Consumer key/secret | WooCommerce REST API access (https only) |
|
|
148
|
+
| Webhook secret | Verifies order webhooks (HMAC-SHA256) |
|
|
149
|
+
| Shop parameter / Shop category / Shop category mode | What's published and how it's sold (see above) |
|
|
150
|
+
| Lead time parameter | Shown on build-to-order products |
|
|
151
|
+
| Parameters shown in the shop | Comma-separated parameter names for the product's specification table |
|
|
152
|
+
| Product title / Product SKU | How products are named. An existing product with the same SKU is **adopted**, not duplicated |
|
|
153
|
+
| Shop currency | Must match the store currency |
|
|
154
|
+
| Stock reserve | Units of every part held back from the shop |
|
|
155
|
+
| Send part images / Public InvenTree URL | Image sync |
|
|
156
|
+
| Show documents on products / Document tag | Which attachments are listed as product downloads |
|
|
157
|
+
| When a part leaves the shop | Draft, private, or move to trash |
|
|
158
|
+
| Automatic sync | Event-driven updates plus a full re-check every 15 minutes |
|
|
159
|
+
| Paid order statuses | Which statuses create a Sales Order (default `processing,completed`) |
|
|
160
|
+
| Customers / Shared customer | One InvenTree customer per shop customer (matched by email), or one shared customer |
|
|
161
|
+
| Issue Sales Orders automatically | Off = web orders arrive as **Pending** for you to check |
|
|
162
|
+
| Note the Sales Order on the shop order | Adds a private note with the InvenTree reference |
|
|
163
|
+
| Account parameter / Credit limit parameter | Company parameters that approve a credit account and cap it |
|
|
164
|
+
| Account payment methods | WooCommerce payment method ids that mean "charge to account" |
|
|
165
|
+
| Sync accounts to the shop | Keep approval and available credit up to date on shop logins |
|
|
166
|
+
| Build to order needs a validated BOM / a locked part | When a build-to-order design counts as released |
|
|
167
|
+
| Build Orders for build-to-order items | Shortfall only, full quantity, or off |
|
|
168
|
+
| Default lead time / Build-to-order note | Lead time when a part has none (default 6 weeks), and a note on build-to-order products |
|
|
169
|
+
| Tell the customer about shipments | Dispatched / delivered emails and completing the order |
|
|
170
|
+
| Shop link secret | Shared with the WordPress plugin; signs quote requests and notifications |
|
|
171
|
+
| Quotes valid for / Expiry reminder | Days a quote can be accepted (30), reminder days before expiry (3) |
|
|
172
|
+
| Largest quote upload / Most files / Upload file types | Quote upload limits |
|
|
173
|
+
| Quote PDF: your details / Quote PDF: terms | Printed on quote PDFs |
|
|
174
|
+
| Quote tax rate / Quote tax name | Tax added on the PDF (10%, GST) |
|
|
175
|
+
| Quote report template / Quote PDF for customers | Which template prints quotes; PDF in the email and My Account |
|
|
176
|
+
|
|
177
|
+
## Quote requests
|
|
178
|
+
|
|
179
|
+
Customers must be **logged in** (no anonymous requests). The flow:
|
|
180
|
+
|
|
181
|
+
1. **Request** (WordPress, the `[inventree_quote_request]` page, or "Request a custom version" on a product):
|
|
182
|
+
any number of items - custom harness, copy of an existing harness, or component - each with quantity,
|
|
183
|
+
description, OEM part number and machine. A harness item needs at least one of: **layout drawing(s) / photos**
|
|
184
|
+
(uploaded), **a sample** (they get a printable sample label with the reference and your address), or **a call
|
|
185
|
+
to discuss** (phone and best time). Plus needed-by date, delivery postcode and notes. The customer and you are
|
|
186
|
+
both emailed. If InvenTree can't be reached the request is queued on the website and retried hourly - the
|
|
187
|
+
customer still gets their reference straight away.
|
|
188
|
+
2. **Work it** (InvenTree dashboard > **Quote Requests**): mark samples received (the customer is emailed),
|
|
189
|
+
record calls, then price each item with one or more lines - an InvenTree part (search), quantity, unit price
|
|
190
|
+
ex tax, lead time (defaults to the default lead time) - or mark it **can't supply** with a reason. **Add charge**
|
|
191
|
+
adds a line with no part (labour, freight, a call-out fee): a fee on the WooCommerce order and an extra line on
|
|
192
|
+
the Sales Order. Build-to-order
|
|
193
|
+
assemblies must be released (BOM validated) before you can send them, same rule as the shop.
|
|
194
|
+
3. **Send**: the quote gets a validity (default 30 days) and the customer is emailed. A part that isn't in the
|
|
195
|
+
shop gets a **hidden, quote-only** WooCommerce product: never shown or buyable in the catalogue, only payable
|
|
196
|
+
through its quote's order.
|
|
197
|
+
4. **Accept** (My Account > Quotes): the customer unticks lines they don't want and accepts. InvenTree creates a
|
|
198
|
+
pending-payment order with exactly those lines at the quoted prices (prices never come from the browser) and
|
|
199
|
+
sends them to pay - online, or "Charge to my account" for approved accounts.
|
|
200
|
+
5. **Paid**: the normal order flow - Sales Order (customer reference = their PO, else the quote reference),
|
|
201
|
+
Build Orders with the quoted lead times - and the quote is marked accepted, with the customer's drawings
|
|
202
|
+
copied onto the Sales Order as attachments.
|
|
203
|
+
6. **Expiry**: a reminder a few days before (default 3), then the quote expires and any unpaid order is
|
|
204
|
+
cancelled. You can also reopen a sent quote to change it, or decline it with a reason.
|
|
205
|
+
|
|
206
|
+
**Quote PDFs.** Quotes print through InvenTree's own report engine: a quote request is a report model (type
|
|
207
|
+
*quote request*), so the PDF is an ordinary report template you can edit in *Admin Center > Reports*. The plugin
|
|
208
|
+
installs **"Quote (web shop)"** the first time a PDF is needed: your InvenTree logo, *Quote PDF: your details*
|
|
209
|
+
(name, ABN, address, phone - one per line), the customer, date / valid until / required by, the priced lines
|
|
210
|
+
with lead times, subtotal ex GST, GST (*Quote tax rate*, default 10%) and total, any items you can't supply,
|
|
211
|
+
the customer's notes and *Quote PDF: terms*. Pick a different template with *Quote report template*.
|
|
212
|
+
|
|
213
|
+
- Staff: **Preview PDF (draft)** / **Download PDF** in the quote window (marked DRAFT until the quote is sent).
|
|
214
|
+
- Customers (*Quote PDF for customers*, on by default): the PDF is attached to the "your quote is ready" email
|
|
215
|
+
and can be downloaded from My Account > Quotes. Only sent (or accepted / expired) quotes, and only their own.
|
|
216
|
+
|
|
217
|
+
Uploads: file types and sizes are settings (default 20 files, 20 MB each, PDFs/images/DXF/DWG/Office/CSV/text).
|
|
218
|
+
Files are stored privately and only staff can download them. Make sure the web servers allow uploads that big:
|
|
219
|
+
nginx `client_max_body_size` on InvenTree, and PHP `upload_max_filesize` / `post_max_size` on the website.
|
|
220
|
+
|
|
221
|
+
The website and InvenTree talk to each other with the **Shop link secret** (set the same value on both sides):
|
|
222
|
+
every call is HMAC-signed with a timestamp, and a quote's files are covered by SHA-256 hashes in the signed
|
|
223
|
+
payload, so nothing can be added or changed in transit.
|
|
224
|
+
|
|
225
|
+
### Pricing in another system (Xero, or your own plugin)
|
|
226
|
+
|
|
227
|
+
Quotes can be priced somewhere else - an accounting system, an ERP - by any InvenTree plugin that offers itself
|
|
228
|
+
as the **quote pricing provider**. With [inventree-xero](https://github.com/SXSLYDA/inventree-xero) 1.5+ (*Web shop
|
|
229
|
+
quote requests* = *Price and send in Xero*), each request becomes a draft Xero quote; you price it in Xero (parts,
|
|
230
|
+
labour, freight, discounts, your own tax rates) and mark it Sent, and the shop sends the customer **Xero's PDF**.
|
|
231
|
+
The shop does everything else as above: emails, My Account, acceptance, payment, the Sales Order, expiry.
|
|
232
|
+
|
|
233
|
+
While a provider is active:
|
|
234
|
+
- the Quote Requests window shows **Priced in Xero** with its quote number and a link; adding lines, sending and
|
|
235
|
+
reopening are done there (samples, calls, notes, can't-supply and declining still work here);
|
|
236
|
+
- customers get the provider's PDF (the InvenTree template is the fallback);
|
|
237
|
+
- customers accept the **whole quote** unless the provider allows line-by-line acceptance.
|
|
238
|
+
|
|
239
|
+
*Where quotes are priced* = *Always in InvenTree* ignores providers. With no provider installed - or the provider
|
|
240
|
+
not ready (inventree-xero in a dry run or disconnected) - everything works as above.
|
|
241
|
+
|
|
242
|
+
**Writing a provider.** No import of this plugin is needed; implement any of these on your plugin class
|
|
243
|
+
(full contract in [`providers.py`](inventree_woocommerce/providers.py)):
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
def woocommerce_quote_provider(self): # required: None = not pricing quotes right now
|
|
247
|
+
return {"name": "MyBooks", "partial_accept": False, "pdf": True}
|
|
248
|
+
|
|
249
|
+
def woocommerce_quote_info(self, quote): # optional: shown to staff
|
|
250
|
+
return {"number": "Q-0042", "status": "Draft", "url": "https://...", "error": ""}
|
|
251
|
+
|
|
252
|
+
def woocommerce_quote_pdf(self, quote): # optional: (bytes, file name) or None
|
|
253
|
+
return pdf_bytes, "Q-0042.pdf"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Then drive the quote through `inventree_woocommerce.quotes.apply_action(quote, data, load_config(),
|
|
257
|
+
source="provider")` - `{"action": "set_lines", "lines": [...]}` (rows with `part_id`, or no `part_id` and a
|
|
258
|
+
`description` for a charge; `quantity`, `unit_price` ex tax, optional `item_id`, `lead_time`), `"send"`
|
|
259
|
+
(optional `valid_days`), `"reopen"`, `"decline"` (with `reason`). Listen for `woocommerce.quote_received` and
|
|
260
|
+
`woocommerce.quote_accepted` (below) to create and close the quote on your side. inventree-xero's `shop_quotes.py`
|
|
261
|
+
is a complete example.
|
|
262
|
+
|
|
263
|
+
## Shipments
|
|
264
|
+
|
|
265
|
+
When a web order's **Shipment** is completed in InvenTree, the customer gets a WooCommerce customer note (emailed):
|
|
266
|
+
"Your order has been dispatched (shipment 1 of 2)", with the tracking number and link if the shipment has them -
|
|
267
|
+
or "ready for collection" for a Local pickup order without tracking. Set the shipment's delivery date and they
|
|
268
|
+
get "delivered on ...". When everything has shipped (or the Sales Order is completed) the WooCommerce order is
|
|
269
|
+
set to Completed. Each message is sent once, however many times the shipment is saved.
|
|
270
|
+
|
|
271
|
+
Rates at checkout are WooCommerce's: e.g. a Local delivery method with postcode zones, plus Local pickup; add a
|
|
272
|
+
carrier plugin later if you post parcels.
|
|
273
|
+
|
|
274
|
+
## Panels in InvenTree
|
|
275
|
+
|
|
276
|
+
- **Dashboard → Web Shop** (staff): setup problems, products in the shop, sync problems, parts awaiting release,
|
|
277
|
+
approved account logins, last sync, failed orders with **Retry**, and recent web orders (account / on hold /
|
|
278
|
+
warnings, linked to their Sales Orders). Buttons: **Sync whole shop**, **Sync accounts**, **Test connection**.
|
|
279
|
+
Add it from the dashboard's widget list.
|
|
280
|
+
- **Part → Web Shop** (salable parts): in the shop or not, and *why not* (inactive, not salable, not flagged,
|
|
281
|
+
shop parameter says No, waiting for BOM validation); sold from stock or built to order; price, stock offered,
|
|
282
|
+
revision, product page and WooCommerce edit links, last sync and any error, and the documents listed.
|
|
283
|
+
Staff get **Send to shop now**.
|
|
284
|
+
- **Sales Order → Web Order** (orders from the shop): paid online or charged to account, on hold, warnings,
|
|
285
|
+
customer PO, payment and transaction, totals, customer note, and its Build Orders.
|
|
286
|
+
|
|
287
|
+
## Payments: online and on account
|
|
288
|
+
|
|
289
|
+
**Online payment** is plain WooCommerce: install and set up a gateway (WooCommerce Stripe Payments, PayPal, ...).
|
|
290
|
+
Paid orders arrive with status *processing* and become Sales Orders. Unpaid ones (a bank transfer waiting in
|
|
291
|
+
*on-hold*) wait until you mark them paid.
|
|
292
|
+
|
|
293
|
+
**Charge to account** (and quote requests) need the companion WordPress plugin, `wordpress/inventree-shop/`:
|
|
294
|
+
|
|
295
|
+
1. Zip the `inventree-shop` folder and upload it in *WordPress > Plugins > Add New > Upload*, then activate.
|
|
296
|
+
It works with both the classic and the block (Cart & Checkout blocks) checkout.
|
|
297
|
+
Then *WooCommerce > InvenTree Shop*: InvenTree address, **Shop link secret** (same as in InvenTree), the quote
|
|
298
|
+
request page (create a page containing `[inventree_quote_request]`), who gets new-request emails, your phone,
|
|
299
|
+
and the address samples are sent to.
|
|
300
|
+
2. *WooCommerce > Settings > Payments > Charge to account (InvenTree)*: enable it, choose whether to ask for
|
|
301
|
+
a purchase order number (optional / required / off), and the status orders get (Processing, or On hold
|
|
302
|
+
if you want to release each one yourself first).
|
|
303
|
+
3. In InvenTree, on the customer company, add parameters:
|
|
304
|
+
- `Shop Account` = `Yes`
|
|
305
|
+
- `Credit Limit` = e.g. `5000` (shop currency; leave it off for no limit)
|
|
306
|
+
4. Make sure each person who orders has a shop login whose email is the company's email or one of its
|
|
307
|
+
**contacts'** emails. The plugin finds their logins hourly (or right away with `POST /accounts/sync/`) and
|
|
308
|
+
stores on each login: approved yes/no, available credit, company name.
|
|
309
|
+
|
|
310
|
+
At checkout, "Charge to my account" is offered only to logged-in, approved customers whose order fits their
|
|
311
|
+
available credit. Available credit = credit limit − what the account owes:
|
|
312
|
+
|
|
313
|
+
- the value of the company's **open** Sales Orders charged to account or entered by hand (web orders paid
|
|
314
|
+
online use no credit), and
|
|
315
|
+
- with the [inventree-xero](https://github.com/SXSLYDA/inventree-xero) plugin installed, the customer's **unpaid
|
|
316
|
+
Xero invoices**. An order whose Xero invoice is approved is then counted once, from Xero, not twice. Credit on
|
|
317
|
+
shop logins is refreshed whenever the Xero plugin reports new balances (event `xero.balances_updated`).
|
|
318
|
+
Turn this off with *Count unpaid Xero invoices*.
|
|
319
|
+
|
|
320
|
+
Without the Xero plugin, invoices waiting for payment aren't visible to InvenTree, so either allow for them in
|
|
321
|
+
the limit or close Sales Orders only once they're paid.
|
|
322
|
+
|
|
323
|
+
When an account order arrives, the plugin checks again with InvenTree's current data. If the company isn't
|
|
324
|
+
approved (any more) or the order is over the limit, the Sales Order is still created but put **On Hold** with
|
|
325
|
+
the reason, so nothing ships by mistake and nothing is lost. The customer's PO number becomes the Sales Order's
|
|
326
|
+
customer reference. Account orders are filed under the account company even if the person typed a different
|
|
327
|
+
company name at checkout.
|
|
328
|
+
|
|
329
|
+
## Build Orders
|
|
330
|
+
|
|
331
|
+
For each line of a new Sales Order, free stock = in stock − allocated to builds − demand from other open sales
|
|
332
|
+
orders.
|
|
333
|
+
|
|
334
|
+
- **Build-to-order** part (must be an assembly) short of stock: a Build Order for the shortfall (or the full
|
|
335
|
+
quantity, if you choose), linked to the Sales Order. Its target date comes from the part's `Lead Time`
|
|
336
|
+
parameter ("2 weeks", "10 working days", "3-4 weeks" - the longer end - or a number of days).
|
|
337
|
+
- **Stock-only** part short of stock (two customers bought the last ones at once): a warning on the order.
|
|
338
|
+
|
|
339
|
+
Build Orders are only made from a released design. If the BOM was edited (or the part unlocked) after the
|
|
340
|
+
customer ordered, the order gets a warning instead, so you re-validate and create the build yourself.
|
|
341
|
+
|
|
342
|
+
In-progress builds aren't counted, so an order is never left without a build. Cancel the new one if an existing
|
|
343
|
+
build covers it. If InvenTree refuses a Build Order (e.g. you require validated or locked BOMs and this one
|
|
344
|
+
isn't), the order is still created and the reason goes in its warnings.
|
|
345
|
+
|
|
346
|
+
## Events for other plugins
|
|
347
|
+
|
|
348
|
+
After a web order is committed the plugin fires InvenTree plugin events (needs *Enable event integration*):
|
|
349
|
+
|
|
350
|
+
| Event | Arguments |
|
|
351
|
+
|---|---|
|
|
352
|
+
| `woocommerce.salesorder_created` | `id` (Sales Order), `woo_order_id`, `woo_order_number`, `on_account`, `held`, `build_ids` |
|
|
353
|
+
| `woocommerce.build_created` | `id` (Build Order), `sales_order`, `part`, `quantity`, `woo_order_id` |
|
|
354
|
+
| `woocommerce.quote_received` | `id` (Quote Request), `reference` |
|
|
355
|
+
| `woocommerce.quote_accepted` | `id` (Quote Request), `reference`, `sales_order` |
|
|
356
|
+
|
|
357
|
+
Another plugin subscribes with `EventMixin`:
|
|
358
|
+
|
|
359
|
+
```python
|
|
360
|
+
def wants_process_event(self, event):
|
|
361
|
+
return event == "woocommerce.build_created"
|
|
362
|
+
|
|
363
|
+
def process_event(self, event, *args, **kwargs):
|
|
364
|
+
build = Build.objects.get(pk=kwargs["id"])
|
|
365
|
+
... # e.g. pin the build to the released design revision
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## What happens to an order
|
|
369
|
+
|
|
370
|
+
When a webhook arrives with a paid status, the plugin creates, in one transaction:
|
|
371
|
+
|
|
372
|
+
- the **customer** with a **contact**, and the **shipping address**. The customer is found by: the company this
|
|
373
|
+
shop login ordered for before, a company with a contact using the billing email, a company with that email -
|
|
374
|
+
or created
|
|
375
|
+
- a **Sales Order** with customer reference = the customer's PO number, or `WC-<order number>`; a link to the
|
|
376
|
+
WooCommerce order; a note with the payment method, transaction id, coupons, customer note and the tax charged
|
|
377
|
+
- a **line item** per product, at the price actually paid (after discounts, ex tax)
|
|
378
|
+
- **extra lines** for shipping and fees
|
|
379
|
+
- **Build Orders** where needed (see above)
|
|
380
|
+
|
|
381
|
+
A product that isn't linked to an InvenTree part still goes on the order, as an extra line flagged for you to
|
|
382
|
+
fix. Every webhook delivery is stored, and an order is only ever turned into one Sales Order, whatever
|
|
383
|
+
WooCommerce retries. Failed orders are retried automatically (up to 5 times), or from the admin page.
|
|
384
|
+
|
|
385
|
+
## Endpoints
|
|
386
|
+
|
|
387
|
+
| Endpoint | Access | Purpose |
|
|
388
|
+
|---|---|---|
|
|
389
|
+
| `POST /plugin/woocommerce/webhook/order/` | WooCommerce (signed) | Order webhook |
|
|
390
|
+
| `GET /plugin/woocommerce/image/<part>/<sig>.<ext>` | Public, signed | Part image for WooCommerce |
|
|
391
|
+
| `GET /plugin/woocommerce/file/<attachment>/<sig>/<name>` | Public, signed | Product document |
|
|
392
|
+
| `GET /plugin/woocommerce/part/<part>/` | Signed in | Part's shop status (the part panel) |
|
|
393
|
+
| `POST /plugin/woocommerce/part/<part>/` | Staff | Re-send one part now |
|
|
394
|
+
| `GET /plugin/woocommerce/salesorder/<so>/` | Signed in | Web order details (the Sales Order panel) |
|
|
395
|
+
| `POST /plugin/woocommerce/quotes/submit/` | WordPress (signed) | New quote request (payload + files) |
|
|
396
|
+
| `POST /plugin/woocommerce/quotes/customer/` | WordPress (signed) | A customer's quotes, for My Account |
|
|
397
|
+
| `POST /plugin/woocommerce/quotes/accept/` | WordPress (signed) | Accept lines, get the payment link |
|
|
398
|
+
| `POST /plugin/woocommerce/quotes/pdf/` | WordPress (signed) | PDF of a customer's sent quote |
|
|
399
|
+
| `GET /plugin/woocommerce/quotes/<id>/pdf/` | Staff | Quote PDF (draft until sent) |
|
|
400
|
+
| `GET/POST /plugin/woocommerce/quotes/...` | Staff | Quote Requests widget (list, detail, actions, files) |
|
|
401
|
+
| `GET /plugin/woocommerce/status/` | Staff | Config problems, last sync, product errors, recent orders |
|
|
402
|
+
| `POST /plugin/woocommerce/sync/` | Staff | Sync now |
|
|
403
|
+
| `POST /plugin/woocommerce/test-connection/` | Staff | Check the API key |
|
|
404
|
+
| `POST /plugin/woocommerce/orders/<id>/retry/` | Staff | Retry a failed order |
|
|
405
|
+
| `POST /plugin/woocommerce/accounts/sync/` | Staff | Refresh account approval/credit on shop logins now |
|
|
406
|
+
| `GET /plugin/woocommerce/accounts/<company id>/` | Staff | An account's approval, limit, credit used and logins |
|
|
407
|
+
|
|
408
|
+
Product links and received orders are also listed in InvenTree's Django admin, with "re-send" and "retry"
|
|
409
|
+
actions.
|
|
410
|
+
|
|
411
|
+
## Security notes
|
|
412
|
+
|
|
413
|
+
- API keys only go over https. Keys and the webhook secret are stored as protected plugin settings.
|
|
414
|
+
- The webhook rejects anything without a valid signature. It never trusts prices from anywhere but the
|
|
415
|
+
signed order body.
|
|
416
|
+
- Image and document links are HMAC-signed per file, and only work while the part is in the shop (and, for
|
|
417
|
+
documents, while the attachment is still marked for the shop). Only PDFs and plain images are shown inline;
|
|
418
|
+
everything else is sent as a download with a sandboxing Content-Security-Policy, so an HTML or SVG attachment
|
|
419
|
+
can't run in InvenTree's domain.
|
|
420
|
+
- Account approval and credit are only ever written by InvenTree (through the REST API key). The WordPress
|
|
421
|
+
plugin checks them again when the order is placed, and InvenTree checks a third time when it arrives.
|
|
422
|
+
|
|
423
|
+
## Roadmap
|
|
424
|
+
|
|
425
|
+
- Product weights and sizes from InvenTree parameters, for carrier rates at checkout
|
|
426
|
+
- Tracking through WooCommerce's order fulfillments (10.2+) when it leaves beta
|
|
427
|
+
|
|
428
|
+
## Development
|
|
429
|
+
|
|
430
|
+
```
|
|
431
|
+
pip install -e . django djangorestframework pytest ruff
|
|
432
|
+
pytest -q tests && ruff check .
|
|
433
|
+
python tools/gen_settings_doc.py # after changing settings: rewrites docs/SETTINGS.md
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
`tests/live/run_live.sh` is what CI runs for the real thing: a fresh InvenTree database with the plugin,
|
|
437
|
+
`tests/integration/check_inventree.py` (every InvenTree-side flow), then a real WordPress from GitHub (SQLite)
|
|
438
|
+
with the inventree-shop plugin talking to InvenTree's dev server (`wordpress/tests/test-gateway.php`,
|
|
439
|
+
`test-quotes.php`):
|
|
440
|
+
|
|
441
|
+
```
|
|
442
|
+
tests/live/run_live.sh /path/to/InvenTree /path/to/venv/bin/python /tmp/shop-live # [--no-wordpress]
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
`tests/frontend/render_panels.mjs` renders the InvenTree panels with React 19 and Mantine 9 in jsdom
|
|
446
|
+
(see the comment at the top for the npm packages it needs). The panels are a single plain JavaScript file,
|
|
447
|
+
`inventree_woocommerce/static/shop_panels.js`, with no build step.
|
|
448
|
+
|
|
449
|
+
**Releasing** is `build-and-bump.ps1` (Windows PowerShell or PowerShell 7): checks, tests, bumps both plugins'
|
|
450
|
+
version, stamps the changelog, builds the WordPress zip, commits and tags `vX.Y.Z`. CI then tests the tag and
|
|
451
|
+
publishes a GitHub release with the WordPress zip. See [docs/RELEASING.md](docs/RELEASING.md).
|
|
452
|
+
|
|
453
|
+
## License
|
|
454
|
+
|
|
455
|
+
MIT
|