Se rendre au contenu
Menu
Cette question a été signalée
5 Réponses
15966 Vues

I'm using Odoo v12.0 
I have added some attributes with values and i want to import my products from Excel file and use those attributes in it.

Problem is it won't let me because it can't find the attribute i'm using in Excel file,.

On the other hand if i use Odoo's default attributes it will import without errors.


Avatar
Ignorer
Meilleure réponse

Hi Amin: 

You can do this in 3 steps.

  1. Go to Inventory > Configuration > Attributes and define the product attributes manually in Odoo. This is the attribute definition.

  2. Go to Inventory > Configuration > Attribute Values and use the import feature to import the valid attribute values.

  3. Go to Inventory > Master Data > Products and import the attribute values for each product.

You will need to create Excel templates for steps 2 and 3. Step 1 can be done manually if the number of attributes is small. If the number of attributes is large you can create a template for this too.

 Hope this helps.

Avatar
Ignorer
Meilleure réponse
Hello,
you need to create the attribute in the product template configuration
this is an example:
if data['ATTRIBUTES']:

for attr in data['ATTRIBUTES']:

attribute, value = attribute.strip(), value.strip()

# Attribute get / create
attribute_id = Attribute.search([
('name', '=', attribute)
])
if not attribute_id:
attribute_id = Attribute.create({'name': attribute,
'create_variant': 'always'})
value_id = AttrValue.create({'name': value,
'attribute_id': attribute_id.id})

else:
# Attribute value get / create
value_id = attribute_id.value_ids \
.filtered(lambda attr_value: attr_value.name == value)

if not value_id:
value_id = AttrValue.create({'name': value,
'attribute_id': attribute_id.id})
value_ids.append(value_id.id)

# Attribute line get / create
attr_line_id = tmpl_id.attribute_line_ids.filtered(
lambda line: line.attribute_id.id == attribute_id.id
)
if not attr_line_id:
AttributeLine.create({
'product_tmpl_id': tmpl_id.id,
'attribute_id': attribute_id.id,
'value_ids': [(4, value_id.id)]
})
else:
attr_line_value_id = attr_line_id.filtered(
lambda line: value_id.id in line.value_ids.ids
)
if not attr_line_value_id:
attr_line_id.value_ids = [(4, value_id.id)]
Avatar
Ignorer
Meilleure réponse

Hi, you can follow https://youtu.be/SgFmOD9Q2S4?si=46y7nPM_rumGs9NU

I hope it helps, thanks

Avatar
Ignorer
Meilleure réponse

Hi Paresh,


I do not have an "Attribute Values" menu - do you know how to configure it?

Thank you,

Kristina

Avatar
Ignorer

You can directly import it from Attributes. Try to export [value_ids/id] and [value_ids/name], you can add extra line and fill and re-import.

Alternatively,
If you are familiar with parent-child relation and wanted to import it from Attribute Values, you can use Odoo Studio in order to add the menu.

Meilleure réponse

Hi  Amin Dehghani,

I think this module can help you: https://apps.odoo.com/apps/modules/12.0/vks_import_excel

Demo: https://www.youtube.com/watch?v=UOBxxnYDIsM&list=PLSKcWRTtEl5qzvRaI-VTGavfReiHS_EEb&index=1

Avatar
Ignorer
Publications associées Réponses Vues Activité
2
mai 25
223
1
juil. 24
1751
2
oct. 23
1631
2
mars 24
2263
1
févr. 22
1713