Is there any way to get the current menuitem ID and action ID of a form view in a python function.I am using v12
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
2
Réponses
10509
Vues
Hi,
Try supering the function fields_view_get
For example
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
menu_id = self._context.get('menu_id', False)
action = self._context.get('action', False)
res = super(YourClassName, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar,submenu=submenu)
return res
Regards
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
1
juil. 22
|
2025 | ||
|
2
juil. 24
|
20615 | ||
|
2
août 23
|
2557 | ||
|
0
janv. 23
|
2136 | ||
|
0
nov. 18
|
2810 |
Not sure whether there is an easy method to get it, suppose if you need to identify the action like, right now suppose we have two forms for same model and we need to identify through which action the form has opened, you can pass something inside the context and based on this context, you can do it right,
If am not clear menu1 -> action1 inside context pass action1: True and for second menu and action pass another context