Skip to Content
Menu
This question has been flagged
2 Replies
1933 Views

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?

Avatar
Discard
Author Best Answer

.

Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

Author

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 ;-)

Author

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

Author

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

Related Posts Replies Views Activity
4
Oct 23
709
1
Nov 24
156
1
Mar 24
2068
2
Jun 23
1672
1
Jan 24
7385