Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
6505 Представления

Suppose I have Product with 3 Variation

Suppose i name attribute_name as ' KG' and have 3 variation 1,5,10

How do i reference the value of variation in sale order ? 

i have try these but it doesn't work

self.product_id.attribute_value_ids.attribute_id.value_ids.name

it gives me this error

  File "/odoo/odoo-server/odoo/models.py", line 4823, in ensure_one
    raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: product.attribute.value(6, 7, 9)

as i need these value to multiply with ordered quantity to give out total quantity

what else can it goes wrong ? 

Аватар
Отменить
Лучший ответ

Hi,

Try this self.product_id.display_name

Thanks


Аватар
Отменить
Автор

Hi, what i want is the value of attribute like 1,5,10 i have tried display_name it doesnt solve. please help

ok, you are getting the error because you have to use a for loop there, try something like this,

productVariants = self.env['product.product']

products = productVariants.search([])

for rec in products:

if rec.attribute_value_ids.name:

print "product with variants", rec.name + '(' + rec.attribute_value_ids.name + ')'

Related Posts Ответы Просмотры Активность
1
июл. 24
3230
6
июн. 20
3588
1
июл. 25
381
2
авг. 23
2383
1
июл. 23
2535