Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
8339 Näkymät

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
Hylkää

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

Paras vastaus

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
Hylkää
Tekijä

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,

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
heinäk. 25
8921
0
helmik. 25
553
2
jouluk. 24
20995
0
syysk. 24
955
2
lokak. 24
3468