Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
8316 Vistas

How do i access the field product_id.product_tmpl_id.type from the sale.order.linemodel.

I have the following button in the xml view:

button name="print_report" string="Print" type="object" icon="gtk-print" attrs="{'invisible':[('product_id.product_tmpl_id.type', '!=', 'product')]}"/>.

With this statement , Odoo shows me the following error:

Uncaught Error: Campo desconocido product_id.product_tmpl_id.type en el dominio [["product_id.product_tmpl_id.type","!=","product"]]

I appreciate your help. Thank you

Avatar
Descartar

can u please update where have you taken that button, is it under 'order line' tree view or outside?
if it is outside the tree view,then try keeping it in...

Mejor respuesta

Hi James, try to make a field related first in the sale.order.line model

Note that this code is in v8 odoo

#declare the selection first

PRODUCT_TYPE = [('consu', 'Consumable'),('service','Service'),('product', 'Product')]

#declare the field

field_related = fields.Selection(PRODUCT_TYPE, related='product_id.product_tmpl_id.type', string='Fields used for attrs', readonly=True)
#on the view.xml
button name="print_report" string="Print" type="object" icon="gtk-print" attrs="{'invisible':[('field_related', '!=', 'product')]}"/>.


Regards,

Avatar
Descartar
Autor

Hi @WilbertTan Odoo I still continued showing me the same message : Campo desconocido field_related en el dominio [["field_related","!=","product"]] I did exactly what you said , but still continues showing me the same error. What else can I do? Thanks.

Hi James, I am not sure about your error. I've tried on my local and it works as intended. Please paste your code and I'll check. Make sure you check the wording too.. In case any typo. Thanks,

Publicaciones relacionadas Respuestas Vistas Actividad
0
feb 25
521
2
dic 24
20952
0
sept 24
938
2
oct 24
3437
3
ago 24
1927