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

Hello All,

I want to hide/invisible some fields in product form based on product category

Thanks in advance

Ankit H Gandhi

Avatar
Hylkää
Paras vastaus

Hello Ankit,

based on the category name you can hide/invisible the field, but for that you have to store the category name into the product form. 

second way is that put one boolean field into product category and based on that boolean field you can hide/invisible the field, but i think in this also you have to store the boolean field value into product form. For this you can see the example in odoo like go to picking form view there is one tab "Detailed Operations" that is based on the stock.picking.type's "show Detailed operation" field.

I hope this will helps you.

Avatar
Hylkää

Good idea.

Tekijä

Hi Mitul,

Your solutions are working for me.

Thank you +1

Tekijä Paras vastaus

Hello All,

Using below code I have acheived solution

Create new related field in Product Template model, Which store the Parent Category Name.

categ_name = fields.Char(related='categ_id.parent_id.name',
string='Category Name')
Define that categ_name field in xml file with invisible='1'
Now add attrs on field

<xpath expr="//field[@name='internal_reference']" position="attributes">

<attribute name="attrs">{'invisible': [('categ_name','=','Saleable')]}</attribute>
</xpath>

 Thanks @ Mitul Shingala

Best Thanks,

Ankit H Gandhi

Avatar
Hylkää
Paras vastaus

Hi, just inherit the view of the product "product_template_form_view" and then do a xpath like this:

<xpath expr="//field[@name='internal_reference']" position="attributes">

<attribute name="attrs">{'invisible': [('categ_id','=','id category')]}</attribute>
</xpath>



Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
tammik. 24
4710
0
syysk. 19
3008
2
maalisk. 15
4498
3
helmik. 24
12720
0
maalisk. 15
3876