Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2767 Lượt xem

I'm ussing Odoo8, and to print price list I click on "Sales/Product variants/Print Pricelist", but it only prints product code, product name, and price, so the only way to distinguish one product variant from another is to look at the code, which is very uncomfortable, and unacceptable to customers. I would like the values of the variants to be displayed next to the product name. I know the view used to print this template is "report_pricelist" but I can't get the attribute values for each variant to print.

I have tried adding the line "<span t-esc =" p.get ['attribute_value_ids.value'] "/>" but I get the following error:


QWebException: "attribute_value_ids.value" when evaluating

"p ['attribute_value_ids.value']"


Any hints on how I can get to print the value of the variant attributes?

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi !

I recently have the same question, I used :
<t t-esc="<your-attribute-query-name.product_template_attribute_value_ids.name" class=""/>

hope it help, and I've well understood your question ;-D

Have a nice day,
Hedge

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks for your answer, but I don't really understand the "your-attribute-query-name" part. To give an example with a standard attribute, you mean in the case of the "color" attribute the correct code would be <t t-esc="color.product_template_attribute_value_ids.name" class=""/>

I tryied it but it doesn't work, in my particular case I get the following error:

QWebException: "'NoneType' object has no attribute 'product_template_attribute_value_ids'" while evaluating 'color.product_template_attribute_value_ids.name'

In fact, first in the .py file under controller folder I have a request

produits=request.env['product.template'].search([('is_published','=',True),('qty_available','>',0)],0,200,'id desc ')

In the xml file :

<t t-foreach="produits" t-as="toto"> <= this "connect" with the request in .py file.

<t t-set="attribute" t-value="toto.product_variant_ids" /> <= this make a "query" of attribute aka variants note the name 'toto' that make "link"

<t t-foreach="attribute" t-as="tutu"> <= this connect with the "attribute" request

and then :

<t t-esc="tutu.product_template_attribute_value_ids.name" class=""/> <= this show each attribute name resulting from tutu

So you can replace Tutu and toto by your query name's :)

<of course, remove my explanations begining by <= :-D)

Hope its help

Tác giả

That's usefull! Thanks, I was trying to modifify the price_list view, but I will try to develop an addon with your info.

With pleasure !!

I've been helped, my turn to help ;-)

Tác giả

Excuseme folk, can you tell how you have defined the class and the function at the py controller?

with odoo.sh or if your run odoo locally

But perhaps you can simply try to use :

p.get ['attribute_value_ids.name’] in code in place of .value

Tác giả

No way to make it work, I will contact somebody to do the work. Thank you any way ;)

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 10 23
1964
Tiered discounts Đã xử lý
1
thg 4 25
1178
1
thg 11 24
1385
1
thg 3 24
3228
2
thg 6 23
2911