Manage client actions from button and wizard
issue3343 review3241002
This commit is contained in:
1 parent
5a6c2fcd0e
commit
25bea1594f
4 files changed
+53
-13
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Manage client actions from button and wizard
|
||||
* Add tree_invisible attribute to button in tree view
|
||||
* Add buttons of the view in actions menu
|
||||
* Don't evaluate anymore relate action with the record
|
||||
|
||||
+2
-2
@@ -870,9 +870,9 @@ class Main(object):
|
||||
return False
|
||||
Preference(rpc._USER, self.get_preferences)
|
||||
|
||||
def sig_win_close(self, widget):
|
||||
def sig_win_close(self, widget=None):
|
||||
self._sig_remove_book(widget,
|
||||
self.notebook.get_nth_page(self.notebook.get_current_page()))
|
||||
self.notebook.get_nth_page(self.notebook.get_current_page()))
|
||||
|
||||
def sig_login(self, widget=None, res=None):
|
||||
if not self.sig_logout(widget, disconnect=False):
|
||||
|
||||
@@ -595,6 +595,15 @@ class Screen(SignalEvent):
|
||||
self.display()
|
||||
return True
|
||||
|
||||
def copy(self):
|
||||
res_ids = self.sel_ids_get()
|
||||
try:
|
||||
new_ids = RPCExecute('model', self.model_name, 'copy', res_ids, {},
|
||||
context=self.context)
|
||||
except RPCException:
|
||||
return
|
||||
self.load(new_ids)
|
||||
|
||||
def set_tree_state(self):
|
||||
view = self.current_view
|
||||
if (not CONFIG['client.save_tree_state']
|
||||
@@ -729,7 +738,7 @@ class Screen(SignalEvent):
|
||||
record = group[idx]
|
||||
break
|
||||
parent = record.parent
|
||||
if not parent:
|
||||
if not parent or record.model_name != parent.model_name:
|
||||
break
|
||||
next = parent.next.get(id(parent.group))
|
||||
while not next:
|
||||
@@ -794,7 +803,7 @@ class Screen(SignalEvent):
|
||||
record = children[-1]
|
||||
else:
|
||||
parent = record.parent
|
||||
if parent:
|
||||
if parent and record.model_name == parent.model_name:
|
||||
record = parent
|
||||
self.current_record = record
|
||||
elif view.view_type == 'calendar':
|
||||
@@ -866,17 +875,45 @@ class Screen(SignalEvent):
|
||||
return
|
||||
ids = [r.id for r in self.selected_records]
|
||||
try:
|
||||
action_id = RPCExecute('model', self.model_name, button['name'],
|
||||
action = RPCExecute('model', self.model_name, button['name'],
|
||||
ids, context=self.context)
|
||||
except RPCException:
|
||||
action_id = None
|
||||
if action_id:
|
||||
Action.execute(action_id, {
|
||||
action = None
|
||||
self.reload(ids, written=True)
|
||||
if isinstance(action, basestring):
|
||||
self.client_action(action)
|
||||
elif action:
|
||||
Action.execute(action, {
|
||||
'model': self.model_name,
|
||||
'id': record.id,
|
||||
'ids': ids,
|
||||
}, context=self.context)
|
||||
self.reload(ids, written=True)
|
||||
|
||||
def client_action(self, action):
|
||||
access = MODELACCESS[self.model_name]
|
||||
if action == 'new':
|
||||
if access['create']:
|
||||
self.new()
|
||||
elif action == 'delete':
|
||||
if access['delete']:
|
||||
self.remove(delete=not self.parent,
|
||||
force_remove=not self.parent)
|
||||
elif action == 'remove':
|
||||
if access['write'] and access['read'] and self.parent:
|
||||
self.remove(remove=True)
|
||||
elif action == 'copy':
|
||||
if access['create']:
|
||||
self.copy()
|
||||
elif action == 'next':
|
||||
self.display_next()
|
||||
elif action == 'previous':
|
||||
self.display_prev()
|
||||
elif action == 'close':
|
||||
from tryton.gui import Main
|
||||
Main.get_main().sig_win_close()
|
||||
elif action.startswith('switch'):
|
||||
_, view_type = action.split(None, 1)
|
||||
self.switch_view(view_type=view_type)
|
||||
|
||||
def get_url(self):
|
||||
query_string = []
|
||||
|
||||
@@ -122,7 +122,7 @@ class Wizard(object):
|
||||
|
||||
def end(self):
|
||||
try:
|
||||
RPCExecute('wizard', self.action, 'delete', self.session_id,
|
||||
return RPCExecute('wizard', self.action, 'delete', self.session_id,
|
||||
process_exception=False)
|
||||
if self.action == 'ir.module.module.config_wizard':
|
||||
rpc.context_reload()
|
||||
@@ -330,7 +330,7 @@ class WizardDialog(Wizard, NoModal):
|
||||
self.dia.show()
|
||||
common.center_window(self.dia, self.parent, self.sensible_widget)
|
||||
|
||||
def destroy(self):
|
||||
def destroy(self, action=None):
|
||||
super(WizardDialog, self).destroy()
|
||||
self.dia.destroy()
|
||||
NoModal.destroy(self)
|
||||
@@ -353,10 +353,12 @@ class WizardDialog(Wizard, NoModal):
|
||||
# Wizard run from a children record so reload parent record
|
||||
ids = [dialog.screen.current_record.id]
|
||||
dialog.screen.reload(ids, written=True)
|
||||
if action:
|
||||
dialog.screen.client_action(action)
|
||||
|
||||
def end(self):
|
||||
super(WizardDialog, self).end()
|
||||
self.destroy()
|
||||
action = super(WizardDialog, self).end()
|
||||
self.destroy(action=action)
|
||||
|
||||
def close(self, widget, event=None):
|
||||
if self.end_state in self.states:
|
||||
|
||||
Reference in new issue
Block a user