Hi,
First you have to inherit name_get function and make it run with context variable 'show_category_path'. In this function set '_rec_name' to 'name'.
class ProductCategory(models.Model):
_inherit = "product.category"
_rec_name = 'name'
@api.depends('name')
def name_get(self):
if self\._context\.get\('show_category_path'\):
\ \ \ \ \ \ \ \ \ \ \ \ new_res\ =\ \[\]
\ \ \ \ \ \ \ \ \ \ \ \ for\ category\ in\ self:
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ name\ =\ category\.complete_name
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ new_res\.append\(\(category\.id,\ name\)\)
\ \ \ \ \ \ \ \ \ \ \ \ ctx\ =\ dict\(self\.env\.context,\ show_category_path=False\)
\ \ \ \ \ \ \ \ \ \ \ \ self\.env\.context\ =\ ctx
\ \ \ \ \ \ \ \ \ \ \ \ return\ new_res
\ \ \ \ \ \ \ \ else:
\ \ \ \ \ \ \ \ \ \ \ \ return\ super\(ProductCategory,\ self\)\.name_get\(\)
Second,\ create\ a\ view\ that\ contains\ action\ and\ view\ definitions\ of\ the\ module\ you\ are\ working\ with\ like\ below\.
The\ first\ context\ change\ is\ in\ action\ definition\ but\ it\ does\ not\ effect\ searchpanel\.\ Because\ of\ this,\ setting\ '_rec_name'\ to\ 'name'\ makes\ it\ work\ as\ you\ need\.\ After\ view\ s\ created\ context\ is\ changed\ with\ your\ variable\ 'show_category_path'\ \.
You\ can\ change\ field\ context\ values\ as\ you\ need\ for\ other\ field\ definitions\ as\ below\.
\ \
\ \ \ \
\ \ \ \ \ \ \ \ Products
\ \ \ \ \ \ \ \ ir\.actions\.act_window
\ \ \ \ \ \ \ \ product\.template
\ \ \ \ \ \ \ \ kanban,tree,form
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \{"search_default_consumable":\ 1,\ 'default_type':\ \ \ \ \ \ \ \ 'product','show_category_path':\ True\}
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Create\ a\ new\ product
\ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \
\ \ \ \ ir\.ui\.view"\ id="product_template_form_view_sale_order_button">
\ \ \ \ \ \ \ \ product\.template\.sale\.order\.button
\ \ \ \ \ \ \ \ product\.template
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{'show_category_path':\ True\}
\ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \
\ \ \ \ \ \
\ \ \ \ "\ rel="ugc">ir\.ui\.view">
\ \ \ \ \ \ \ \ app\.product\.template\.search
\ \ \ \ \ \ \ \ product\.template
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \
\ \ \ \
\ \ \ \ "\ rel="ugc">ir\.ui\.view">
\ \ \ \ \ \ \ \ app.stock.quant.template.search
stock.quant