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_idsAt 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 notdefault_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:


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 ]
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
Explanation
Last updated