Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
2748 Vistas

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
Descartar
Autor Mejor respuesta

.

Avatar
Descartar
Mejor respuesta

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
Descartar
Autor

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

Autor

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

Autor

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

Autor

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

Publicaciones relacionadas Respuestas Vistas Actividad
4
oct 23
1960
1
abr 25
1164
1
nov 24
1372
1
mar 24
3222
2
jun 23
2905