Fix action button sensibility
Allow to run action if no record is selected. issue3685 review3611003
This commit is contained in:
1 parent
df6f7986d3
commit
51a815b31d
3 files changed
+10
-4
No files matched your search
@@ -95,7 +95,7 @@ class Action(object):
|
||||
action.setdefault('pyson_domain', '[]')
|
||||
ctx = {
|
||||
'active_model': data.get('res_model'),
|
||||
'active_id': data.get('id', False),
|
||||
'active_id': data.get('id'),
|
||||
'active_ids': data.get('ids', []),
|
||||
}
|
||||
ctx.update(rpc.CONTEXT)
|
||||
|
||||
@@ -415,7 +415,7 @@ class Form(SignalEvent, TabContent):
|
||||
name = '_'
|
||||
if signal_data[0]:
|
||||
name = str(signal_data[0])
|
||||
for button_id in ('print', 'action', 'relate', 'email', 'open', 'save',
|
||||
for button_id in ('print', 'relate', 'email', 'open', 'save',
|
||||
'attach'):
|
||||
button = self.buttons[button_id]
|
||||
can_be_sensitive = getattr(button, '_can_be_sensitive', True)
|
||||
@@ -465,7 +465,8 @@ class Form(SignalEvent, TabContent):
|
||||
action = action.copy()
|
||||
if not self.screen.save_current():
|
||||
return
|
||||
record_id = self.screen.id_get()
|
||||
record_id = (self.screen.current_record.id
|
||||
if self.screen.current_record else None)
|
||||
record_ids = [r.id for r in self.screen.selected_records]
|
||||
action = Action.evaluate(action, atype, self.screen.current_record)
|
||||
data = {
|
||||
@@ -507,7 +508,9 @@ class Form(SignalEvent, TabContent):
|
||||
tbutton.connect('toggled', self.action_popup)
|
||||
self.tooltips.set_tip(tbutton, tooltip)
|
||||
self.buttons[special_action] = tbutton
|
||||
tbutton._can_be_sensitive = bool(tbutton._menu.get_children())
|
||||
if action_type != 'action':
|
||||
tbutton._can_be_sensitive = bool(
|
||||
tbutton._menu.get_children())
|
||||
else:
|
||||
tbutton = gtk.SeparatorToolItem()
|
||||
gtktoolbar.insert(tbutton, -1)
|
||||
|
||||
@@ -858,6 +858,9 @@ class Screen(SignalEvent):
|
||||
states = record.expr_eval(button.attrs.get('states', {}))
|
||||
return not (states.get('invisible') or states.get('readonly'))
|
||||
|
||||
if not self.selected_records:
|
||||
return []
|
||||
|
||||
buttons = self.current_view.get_buttons()
|
||||
|
||||
for record in self.selected_records:
|
||||
|
||||
Reference in new issue
Block a user