SharpSync
  • Welcome
  • Fundamentals
    • Getting Started
      • Registration
      • Landing Page
      • Support
      • Subscription
    • Data Sources
    • Property Mappings
    • Rule Templates
    • BOM Comparison
    • Data Safety
    • Troubleshooting
      • Duplicate component paths
      • OAuth 2.0
  • Data Sources
    • Autodesk Inventor
    • CSV
      • Getting Started
      • Importing a Bill of Materials (BOM)
    • MS Dynamics 365 Business Central
      • Getting Started
      • Item Fields Json & Internal Names
      • Resource Fields Json & Internal Names
      • List Names For nestedObject Mappings
    • NetSuite
      • OAuth Setup
        • Permissions
      • Suite API Setup
      • Create an uploads folder
      • Setting up a thumbnail folder
      • Authentication + Configuration
      • Common setup
        • Configure quantity mapping
        • Configure accounts mappings
        • Configure itemType mapping
        • Configure isPhantom mapping
        • Configure subsidiary mapping
        • Configure price mapping
        • Configure Where Used Link mapping
        • Configure thumbnail mapping
        • Common Mapping Rules
        • Common List names
      • Advanced Bill of Materials
      • Configure Server Side Script
        • Example Server Side Script
      • Configure SharpSync to use Server Side Script
      • Configure Routings
      • Integration tips
      • Troubleshooting
    • Odoo
      • Getting Started
        • Authentication + Configuration
        • Debugging tips
      • Common Setup
        • Map BOM Codes
        • Map BOM Types
        • Map Attribute Values
          • Reading Attributes - Overview
          • Display All Attribute Names
          • Display Single Attribute Values
          • Writing attributes
      • Product Management
      • Hosting Options
      • List Names
      • Permissions
    • Onshape
      • Getting Started
      • Setting up Derivatives
    • Propel PLM
      • Getting Started
    • SolidWorks
    • SolidWorks PDM
      • Downloading and installing the add-in
      • Configure the add-in
      • Setting up the Solidworks PDM Web 2
      • Troubleshooting
      • Submitting a BOM for update
  • Property Mappings
    • Property Mapping Settings
      • Rendering Types
    • Rule Templates
      • Import / Export
        • Append text
        • Calculate number
        • Export manipulation
        • Format as decimal number
        • Prepend text
        • Remove property
        • Replace all instances
        • Replace first instance
        • Round to nearest X
        • Select from JSON
        • Set cell value
        • Set empty cells
        • Text manipulation
      • Display
        • Number between
        • Text contains
        • Text ends with
        • Text evaluation
        • Text is a number
        • Text is exactly
        • Text is in list
        • Text is not a number
        • Text is not empty
        • Text is not in list
        • Text length between
        • Text length is exactly
        • Text maximum length
        • Text minimum length
        • Text not contains
        • Text not ends with
        • Text not starts with
        • Text starts with
  • Advanced
    • Derivatives
    • Advanced Scripting
  • User management
    • User Management
    • Application Permissions
Powered by GitBook
On this page
  • Write the values back to Odoo
  • Example: Legs
  1. Data Sources
  2. Odoo
  3. Common Setup
  4. Map Attribute Values

Writing attributes

Write the values back to Odoo

Care should be taken writing values back to Odoo as it can result in data loss. A rich feature update is scheduled for development which will enable multi configuration export / import per assembly or part.

During the development of this feature, writing of multiple attribute values will become supported. Until such time, only a single value is supported. You may have multiple attribute lines, but only a single value per line.

TLDR; Only a single value per attribute line is supported for now!

The reason for this is that multiple variants are created when setting attribute line ids, and multiple default_code (Internal reference in Odoo) cannot be set using the single component's name or part number.

There is no way to generate internal references for other configurations. The CAD system has to send this data, which we cannot do at the time of writing this. It is coming in a future update.

When writing values to Odoo you require the following pieces to put the puzzle together:

  • The attribute line id

  • The attribute value operation to perform (add / update / delete)

  • The value to set (e.g. Color = Red or Legs = Steel)

This setup requires the following mappings:

  • At least 1 Property Mapping for the secondary accessor product.template.attribute_line_ids

  • At least 1 Property Mapping for the new or existing value to use (single value)

  • At least a mapping that sets product.template.default_code (or your primary search identifier in the datasource if its not default_code

You may repeat this single value setup for other attributes, as long as you follow the 'single-line-single-attribute-value' setup we will support your configuration

Until further notice we do not support multiple value updates while setting the default_code. Should you choose to still sync multiple values (it is possible), please note that we will not be able to provide support. It doesn't mean it can't be done - we just can't support you right now.

Create a new Property Mapping for a single attribute line id. Follow the guide to Display Single Attribute Values.

Your display in SharpSync and Odoo should now look something like this:

SharpSync
Odoo

Example: Legs

The data we want to send to Odoo is in the form

[ {attributeId} , [ {arrayOfValues} ] ]

Each value for each attribute must be combined into a final attribute value, so multiples would look like this

[ [ {attributeId1} , [ {arrayOfValues1} ] ], [ {attributeId2} , [ {arrayOfValues2} ] ] ]

Or more concisely represented

[ attribute1Values, attribute2Values ]

Data
Description

1

The attribute (this is the ID for Legs)

2

The attribute value id (this is the ID for Aluminium)

[[ 1, [2] ]]

The combined attribute id and value id

[ [ 1, [2] ],

[ 2, [11,12] ]

]

The combined attribute ids and value ids. Attribute 1 (Legs), Value ID 2 (Aluminium) Attribute 2 (Color), Value ID 5 and 8 (Red, Satin Black)

To do this, we create a mapping for the Legs (See Display Single Attribute Values )

Once this is setup, we have the ID of the attribute 'Legs', which is the value 1

Then we take the value 1 and combine it with the possible values from the attribute value ids

We do this with the following export manipulation rule

const attributeAccessorName = "attributeLegsName";
const attributeIdInOdoo = attributeAccessorName in rowData.modifications  ? rowData.modifications[attributeAccessorName] : rowData.cells[attributeAccessorName];
const isNewRow = !rowData.isFoundInSecondaryDatasource && rowData.isMissingInSecondaryDatasource;

if (isNewRow)
  return [[attributeIdInOdoo, [s]]];

return [[attributeIdInOdoo[0], [s]]];

Explanation


// The name of the property mapping accessor that contains the attribute id
const attributeAccessorName = "attributeLegsName";
// this checks if the attributeId has been modified (rowData.modifications). 
// If it has, use it, otherwise fall back to the value in the rowData.cells (value of the primary)
const attributeIdInOdoo = attributeAccessorName in rowData.modifications  ? rowData.modifications[attributeAccessorName] : rowData.cells[attributeAccessorName];
// a value checking if the row is new. If it is, there will not be an existing value
const isNewRow = !rowData.isFoundInSecondaryDatasource && rowData.isMissingInSecondaryDatasource;

if (isNewRow)
  return [[attributeIdInOdoo, [s]]];

return [[attributeIdInOdoo[0], [s]]];
PreviousDisplay Single Attribute ValuesNextProduct Management

Last updated 16 days ago