Display Single Attribute Values
Last updated
Last updated
The goal is to display a single attribute, and select a different value. Once the BOM is submitted the new value will take effect.
We start by specifying the list name product.attribute
. The list product.attribute
is special in that you can expand upon the query by adding an attribute name at the end in square brackets. Use the steps in the previous topic to duplicate the mapping.
To view the values of an individual Product Template's attribute in SharpSync, use the Property Mapping list product.attribute["{nestedListName"}]
(see also )
Start by adding a for
product.template.attribute_line_ids
Summary of the settings below:
Primary Accessor
(Unmapped)
Secondary Accessor
product.template.attribute_line_ids
List Name
product.attribute["Legs"]
List Value Selector
{id}:{name}, attribute_id : {attribute_id[0]}
Prefer Odoo Value
checked
Update Odoo on submit
Checked.
Warning! Enable only if mapping a single value !
[You have been warned!] . Always always test attribute mappings.
If you are unsure, leave this unchecked
Render Type
Advanced List
We'll specify our list name and add an attribute name 'Legs' as follows:
product.attribute["Legs"]
Click the Save button at the bottom, then the 'refresh' icon below the List Value Selector
item.
A new list of items is returned
1:Steel, attribute_id : 1|2:Aluminium, attribute_id : 1|8:Custom, attribute_id : 1
In SharpSync make the following changes to the Property Mapping:
Rendering Type
Advanced List
List Display Selector
name
List Value Selector
id
List Items
Click the Save
button at the bottom.
You now have the values in the list, but nothing will yet display in the Bill Of Materials view.
The next step will be to parse the values from Odoo so that it automatically selects the correct value onscreen when the BOM is loaded from Odoo.
The values that arrive from Odoo are complex nested values (the type is nestedObject
in SharpSync) and looks something like this:
This must be converted to a more readable format for the BOM comparison screen, so we'll make use of an Import Rule
.
Navigate to the Property Mapping. Add a new Import Rule to parse the values from Odoo for Legs:
Rule Type
Import
Rule Name
Text Manipulation
Value
Enabled for
Odoo only
This parses the values from Odoo and filters out everything but the first value. If you want to return all the values from Odoo, change the last line from
to
This will return a list of 'ids' as a result, allow selection of the values from the list of values on the screen.
We can now read the values. The next step is to put an optional blocking rule in place.
Add a new rule which will block multiple values from being submitted to Odoo.
Navigate to the Property Mapping.
Add a new Import Rule:
Rule Type
Import
Rule Name
Text Evaluation
Value
On Rule Failure Action:
block
At the time of writing, we do not support multiple value updates. You will have to change the rendering type from Advanced MultiSelect List to Advanced List (Single selection)