Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ repos:
- --settings=.
exclude: /__init__\.py$
- repo: https://github.com/acsone/setuptools-odoo
rev: 3.1.8
rev: 3.3.2
hooks:
- id: setuptools-odoo-make-default
- id: setuptools-odoo-get-requirements
Expand Down
302 changes: 302 additions & 0 deletions connector_onshape/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
=================
Onshape Connector
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:cad63694c119ae4a13923eac90ec6479b6ad3a428107dae056d5042bc988d120
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fconnector-lightgray.png?logo=github
:target: https://github.com/OCA/connector/tree/16.0/connector_onshape
:alt: OCA/connector
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/connector-16-0/connector-16-0-connector_onshape
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/connector&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module provides bidirectional synchronization between Odoo and
`Onshape <https://www.onshape.com>`__ cloud CAD/PLM platform.

It synchronizes:

- **Documents**: Import Onshape documents and their elements (part
studios, assemblies, drawings).
- **Products**: Bind Onshape parts to Odoo products using a 4-strategy
SKU matching algorithm (exact filename, part number, McMaster catalog,
case-insensitive).
- **Bills of Materials**: Import Onshape assembly BOMs as ``mrp.bom``
records with component match scoring.
- **Metadata Export**: Push Odoo product SKUs and names back to Onshape
part metadata (Part Number, Description fields).
- **Webhooks**: Receive real-time notifications from Onshape for
metadata changes, workflow transitions, and revision creation.

The module uses the OCA Connector framework with queue_job for
asynchronous processing and supports both HMAC (API Key) and OAuth2 (App
Store) authentication modes.

**Table of contents**

.. contents::
:local:

Configuration
=============

Onshape Developer Portal Setup
------------------------------

Before configuring the Odoo backend, you need API credentials from
Onshape.

**HMAC API Keys (quickest to start):**

1. Sign in at https://cad.onshape.com

2. Go to your **User Menu** (top-right) > **My Account** > **API keys**
(or visit https://dev-portal.onshape.com/keys directly)

3. Click **Create new API key**

4. Give it a name (e.g. ``Odoo Connector``) and select scopes:

- ``OAuth2Read`` — read documents, parts, assemblies, metadata
- ``OAuth2Write`` — write metadata (Part Number, Description)
- ``OAuth2Delete`` — only if you need webhook management

5. Copy the **Access key** and **Secret key** — the secret is shown only
once.

**Finding your Company ID (Enterprise/Professional only):**

1. Go to https://cad.onshape.com
2. Click **Company** in the left sidebar
3. The URL will show the company ID:
``https://cad.onshape.com/company/<COMPANY_ID>``
4. Leave this field empty on Education/Student/Free plans.

**OAuth2 App Store (recommended for production):**

HMAC keys and private OAuth2 apps count against an annual API quota
(~10,000 calls/user/year for Enterprise). Only **publicly listed App
Store apps** are exempt. To set up OAuth2:

1. Go to https://dev-portal.onshape.com > **OAuth applications**

2. Click **Create new OAuth application**

3. Fill in:

- **Name**: Your app name (e.g. ``My Odoo Connector``)
- **Primary Format**: ``com.yourcompany.odoo-connector`` (cannot
change later)
- **Redirect URLs**:
``https://your-odoo.com/connector_onshape/oauth/callback``
- **OAuth Scopes**: ``OAuth2Read``, ``OAuth2Write``

4. For quota exemption, submit the app for App Store review by emailing
``onshape-developer-relations@ptc.com``

Odoo Backend Configuration
--------------------------

1. Install the ``connector_onshape`` module.

2. Go to **Onshape > Configuration > Backends** and create a new
backend.

3. Fill in the connection details:

- **Base URL**: ``https://cad.onshape.com`` (default)
- **Authentication Mode**: HMAC or OAuth2
- **Onshape Company ID**: From step above (leave empty for EDU/Free
plans)

4. For **HMAC** mode, enter the **API Access Key** and **API Secret
Key**.

5. For **OAuth2** mode:

a. Enter the **OAuth2 Client ID** and **Client Secret** from the
Onshape Developer Portal. Make sure you copy the **complete** secret
including any trailing ``=`` padding characters (base64 encoding).

b. Copy the **OAuth2 Redirect URI** shown on the form (click the
clipboard icon) and register it in your Onshape app's redirect URLs.

c. Click **Authorize with Onshape** — you will be redirected to
Onshape to approve access. After approval, Onshape redirects back to
Odoo and the token is stored automatically.

d. The **OAuth2 Authorized** checkbox confirms the token was
obtained.

6. Click **Check Credentials** — should show a green success
notification.

7. Click **Activate** to enable the backend.

Import Settings
---------------

- **Auto-create Products**: When enabled, creates new Odoo products for
Onshape parts that don't match any existing SKU. When disabled,
unmatched parts are skipped (no binding created).
- **Default Product Category**: Category assigned to auto-created
products.
- **Import Products Since**: Only import parts modified after this date
(for incremental sync).

Webhooks (Real-Time Sync)
-------------------------

Webhooks push Onshape changes to Odoo in real time instead of waiting
for the next scheduled sync.

1. Click **Generate Secret** on the backend form to create a webhook
secret.

2. Click **Register Webhook** to register webhooks with Onshape.

- **Enterprise/Professional** (Company ID set): registers a single
company-wide webhook.
- **Education/Free** (no Company ID): registers one webhook per
document. New documents imported later get webhooks automatically.

3. The **Webhook URL** field (read-only) shows the endpoint URL. Ensure
your Odoo instance is reachable from the internet at that address
(Onshape must be able to POST to it).

Clicking **Register Webhook** again cleans up stale duplicates and only
registers for documents that are missing a webhook. The webhook ID is
tracked on each document record.

Events handled:

- ``onshape.model.lifecycle.metadata`` — re-imports part metadata
- ``onshape.model.lifecycle.createversion`` — syncs document on version
creation
- ``onshape.workflow.transition`` — updates lifecycle state (Enterprise
only)
- ``onshape.revision.created`` — marks parts as released (Enterprise
only)
- ``webhook.unregister`` — clears tracked webhook ID when Onshape
expires it

Scheduled Sync (Cron Jobs)
--------------------------

Three cron jobs are created (disabled by default):

- **Onshape: Import Documents** — every 6 hours
- **Onshape: Import Products** — every 6 hours
- **Onshape: Import BOMs** — every 12 hours

Enable them in **Settings > Technical > Automation > Scheduled Actions**
when you're ready for automatic background synchronization.

Usage
=====

Import Documents
----------------

Click **Import Documents** on the backend form to fetch all Onshape
documents from your Onshape account. Documents are created with their
elements (part studios, assemblies, drawings).

Import Products
---------------

Click **Import Products** to scan all part studio elements and create
product bindings. The module uses a 4-strategy matching algorithm:

1. **Exact filename**: Part name matches an Odoo product SKU
2. **Part number**: Onshape Part Number metadata matches an Odoo SKU
3. **McMaster catalog**: Extracted catalog numbers (e.g., 90185A632)
match
4. **Case-insensitive**: Fallback case-insensitive match

Unmatched parts will be auto-created as products if configured.

Import BOMs
-----------

Click **Import BOMs** to fetch assembly BOMs from Onshape and create
``mrp.bom`` records. Each BOM includes a **match score** indicating what
percentage of Onshape components were matched to Odoo products.

Export Part Numbers
-------------------

Click **Export Part Numbers** to push Odoo product SKUs and names back
to Onshape. This writes the ``default_code`` as "Part Number" and
``name`` as "Description" in Onshape metadata.

Automatic Export
----------------

When a product's ``default_code`` or ``name`` is changed in Odoo, a
background job is automatically queued to export the update to Onshape
(if the product is bound to an Onshape part).

Import Wizard
-------------

Use **Onshape > Onshape Data > Import from Onshape** for a guided import
process with options for documents-only, documents+products, or full
sync including BOMs.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/connector/issues/new?body=module:%20connector_onshape%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Kencove Farm Fence Supplies

Contributors
------------

- Don Kendall dkendall@kencove.com

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/connector <https://github.com/OCA/connector/tree/16.0/connector_onshape>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions connector_onshape/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Kencove Farm Fence Supplies
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import components, controllers, models, wizards
38 changes: 38 additions & 0 deletions connector_onshape/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 Kencove Farm Fence Supplies
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Onshape Connector",
"version": "16.0.1.0.0",
"category": "Connector",
"summary": "Synchronize products and BOMs with Onshape PLM",
"author": "Kencove Farm Fence Supplies, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector",
"license": "AGPL-3",
"development_status": "Beta",
"depends": [
"connector",
"component",
"component_event",
"queue_job",
"product",
"mrp",
],
"external_dependencies": {
"python": ["requests"],
},
"data": [
"security/onshape_security.xml",
"security/ir.model.access.csv",
"data/queue_job_channel_data.xml",
"data/queue_job_function_data.xml",
"data/ir_cron_data.xml",
"wizards/onshape_import_wizard_views.xml",
"views/onshape_backend_views.xml",
"views/onshape_document_views.xml",
"views/onshape_product_views.xml",
"views/product_template_views.xml",
"views/mrp_bom_views.xml",
],
"installable": True,
"application": False,
}
4 changes: 4 additions & 0 deletions connector_onshape/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 Kencove Farm Fence Supplies
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import core, adapter, binder, exporter, importer, listener, mapper
Loading