Skip to Content
Menu
This question has been flagged
1 Reply
7389 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

Avatar
Discard

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

Best Answer

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
Discard
Author

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,

Related Posts Replies Views Activity
0
Dec 24
3
0
Dec 24
3
0
Sep 24
126
2
Oct 24
2441
3
Aug 24
529