Map Attribute Values

Some terms before you read the below:

Term
Explanation

product.template

A product. The top level type which encapsulates all the information about a product that is sold on the web portal

product.product

A product variant. A different version of the product.template. It has something different like a color, material or finish, but has the same underlying geometry or shares some properties which are similar.

There is a 1:1 or 1:N relationship between product.templateand product.product, depending on the number of attributes defined.

unique identifier

The value on a product.template or product.product that uniquely identifies it in the entire Odoo system.

Adding an removing attributes in Odoo

When adding new attributes in Odoo, Odoo automatically creates new variants. It does not set the internal reference (you have to do that), but it creates multiple variants. Product Templates and Product Variants have a 1:N relationship in Odoo. For a single template attribute value, it is a 1:1 relationship. Anything more than that results in multiple product variants.

For every attribute value added per attribute line on a product template, a new variant is created

[You can add new Attributes (and in doing so, product variants) by navigating to the Attributes and variants Tab in Odoo and adding new values]

Single attributes values

If a single attribute with 1 value is added, the default product.product variant is updated with that value.

If another attribute is added, also only with a single value, only 1 variant is available.

If any more than a single value is added, then an additional variants are created with the new values:

Adding an attribute creates additional product variants (product.product) with the new value.

SharpSync does not currently support the generation of multiple variant lines with multiple attribute values. Only a single attribute value is supported.

Multiple attributes

Multiple attributes in Odoo automatically adds multiple variants. It increases the relationship from a 1xproduct.template:1x product.productto a 1T:N:M relationship where

  • 1T = 1 Product Template

  • N = N number of attributes

  • M = M number of variants

Below is an image that illustrates this for the product A1-PN, where 2 different attributes with 2 values each results in 4 variants.

Adding multiple attributes increases the count of product variants (product.product)

Displaying an attribute as a Property Mapping

Each configuration's properties in the CAD system will be mapped as an attribute in Odoo. Let's say we have the following setup:

  • Assembly A1-PN, with configuration

    • C1

    • C2

Each configuration has a Color value.

  • C1, Color = Red

  • C2, Color = Satin Black.

Each configuration has a Finish value

  • C1, Finish = Matte

  • C1, Finish = Gloss

To display these values in SharpSync, we map the following Property Mappings

  • product.template.attributes

There is a 1:1 mapping in the BOM comparison screen for Color. Sending the BOM to SharpSync should display either a value of Blue OR Red for the part. Not both.

There is a 1:1 mapping in the BOM comparison screen for Finish. Sending the BOM to SharpSync should display either a value of Satin Black OR Bronze for the part. Not both.

From SharpSync ⇒ Odoo

Attributes in Odoo are analogous to configuration values in a CAD system. When adding an attribute to a product template or a product variant, you are creating a new variant (new configuration) of that product.

To setup attribute lists in SharpSync these are major steps:

  • Read the values

  • Setup a Render Type

  • Write the values back to Odoo

Limitations in Odoo on Uniqueness

Odoo uses attribute values like CAD configurations.

Let's sketch a hypothetical scenario which, while possible in Odoo, is not supported by SharpSync.

You have a product template (T1) with variants (v1, v2, v3) which were created through setting some variant attribute values.

You add a unique internal reference to each variant namely

  • PT1-PV1-I

  • PT1-PV2-I

  • PT1-PV3-I

You then archive, say, PV2. In this step, the internal reference is no longer considered as part of the uniqueness rule in Odoo.

You then rename PV3 to PV2.

Finally, you unarchive the original PV2.

The situation you've now arrived at is that PV2 contains 2 product variants (product.product) instances with the same internal reference. Attempting to save either will result in an error in Odoo informing you that you have a unique constraint violation. But importantly, it does allow the duplicates!.

In SharpSync, when setting the primary search identifier to default_code (which is the internal name of the internal reference) field, SharpSync will search for and sometimes find both items if both variants are linked to the same BOM. This will result in an error stating that you have duplicate items.

The fix

In Odoo - change the internal or unique reference for the item shown in SharpSync to something which makes it unique again.

Last updated