Hi,
To conditionally hide a QWeb action
button using the `get_views` method, you can override the method and
include your logic to filter the views based on the model's state.
Here's a concise example:
from odoo import models
class YourModel(models.Model):
_inherit = 'your.model'
def get_views(self, views, options=None):
result = super(YourModel, self).get_views(views, options=options)
# Add conditional logic based on the model's state
if self.state != 'desired_state':
# Modify the result to hide the button
result = [view for view in result if view[0] != 'form']
return result
In this example:
- Replace `'desired_state'` with the condition you want to check.
- Adjust the filtering logic as needed to hide or show the views accordingly.
Hope it helps