model is 'product.category ', want to inhereit and add a field 'level' to add the levels to find which level record i want.
we knew that by default (as recommended) that first entry 'All' here should present to start the parent child relations.
when user create a new category and select All as its parent, we knew that its level is 1 and we can add 2, programatically it should be parent level + 1 ... so we can add levels of any depth.
i don't know how to code it, so please help me for the below onchange function (or any other better approach, please specify), modify it to achieve what i wants to have.
@api.onchange(parent_id):
def _onchange_parent_id(self):
find the level of parent here...
self.level = parent_level + 1
regards