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
257 changes: 257 additions & 0 deletions connector_onshape/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
=================
Onshape Connector
=================

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

.. |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 Team / Company ID:**

1. Go to https://cad.onshape.com
2. Click **Teams** in the left sidebar
3. Click on your team — the URL will show the team ID:
``https://cad.onshape.com/team/<TEAM_ID>``

**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. ``Kencove 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
* **API Key / Secret**: From step above (HMAC mode)
* **Team / Company ID**: From step above

4. Click **Check Credentials** — should show a green success notification.
5. 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. In Odoo, note your backend ID (visible in the URL when viewing the backend
form, e.g. ``/web#id=1&model=onshape.backend``).

2. Your webhook URL is:
``https://your-odoo-instance.com/connector_onshape/webhook/<backend_id>``

3. Generate a webhook secret (any random string, e.g. ``openssl rand -hex 32``)
and enter it in the **Webhook Secret** field on the backend form.

4. Register the webhook in Onshape. You can do this via the Onshape API
or by clicking the **Register Webhook** button (if available) on the backend.
The module listens for these events:

* ``onshape.model.lifecycle.metadata`` — re-imports part metadata
* ``onshape.workflow.transition`` — updates lifecycle state
* ``onshape.revision.created`` — marks parts as released
* ``onshape.model.lifecycle.createversion`` — logs version creation

5. Ensure your Odoo instance is reachable from the internet (Onshape must
be able to POST to the webhook URL).

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 team. 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
~~~~~~~~~~~~

* Kencove Farm Fence Supplies

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.
1 change: 1 addition & 0 deletions connector_onshape/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import components, controllers, models, wizards
37 changes: 37 additions & 0 deletions connector_onshape/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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",
"depends": [
"connector",
"component",
"component_event",
"queue_job",
"product",
"mrp",
],
"external_dependencies": {
"python": [],
},
"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": True,
}
1 change: 1 addition & 0 deletions connector_onshape/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import adapter, binder, core, exporter, importer, listener, mapper
Loading
Loading