Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How to access a field of another model in a button with the attrs attribute?

James Ford
on 3/10/16, 11:55 AM 563 views

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

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...

on 3/11/16, 6:07 AM
Wilbert Tan
On 3/10/16, 11:11 PM

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')]}"/>.


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.

James Ford
on 3/11/16, 8:46 AM

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,

Wilbert Tan
on 3/13/16, 10:00 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 3/10/16, 11:55 AM
Seen: 563 times
Last updated: 3/10/16, 11:11 PM