Add plugin and workflow plugin
This commit is contained in:
1 parent
23febf27f1
commit
1252a17f26
5 files changed
+53
-11
No files matched your search
+2
-2
@@ -753,14 +753,14 @@ class Main(object):
|
||||
except_id=except_id)
|
||||
|
||||
def sig_plugin_execute(self, widget):
|
||||
import plugins
|
||||
import tryton.plugin
|
||||
page = self.notebook.get_current_page()
|
||||
datas = {
|
||||
'model': self.pages[page].model,
|
||||
'ids': self.pages[page].ids_get(),
|
||||
'id': self.pages[page].id_get(),
|
||||
}
|
||||
plugins.execute(datas)
|
||||
tryton.plugin.execute(datas, self.window)
|
||||
|
||||
@staticmethod
|
||||
def sig_quit(widget):
|
||||
|
||||
@@ -237,6 +237,10 @@ class Tree(SignalEvent):
|
||||
res = self.tree_res.sel_ids_get()
|
||||
return res
|
||||
|
||||
def id_get(self):
|
||||
res = self.tree_res.sel_id_get()
|
||||
return res
|
||||
|
||||
def sig_save_as(self, widget=None):
|
||||
win = WinExport(self.model, self.ids_get(),
|
||||
self.tree_res.fields, [], parent=self.window,
|
||||
|
||||
@@ -332,15 +332,9 @@ class ViewTree(object):
|
||||
return [int(model.get_value(model.get_iter(x), 0)) for x in iters]
|
||||
|
||||
def sel_id_get(self):
|
||||
sel = self.view.get_selection().get_selected()
|
||||
if sel == None:
|
||||
return None
|
||||
(model, i) = sel
|
||||
if not i:
|
||||
return None
|
||||
res = model.get_value(i, 0)
|
||||
if res != None:
|
||||
return int(res)
|
||||
res = self.sel_ids_get()
|
||||
if res:
|
||||
res = res[0]
|
||||
return res
|
||||
|
||||
def value_get(self, col):
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import common
|
||||
import os
|
||||
import imp
|
||||
|
||||
PLUGINS_PATH = os.path.join(os.path.dirname(__file__), 'plugins')
|
||||
|
||||
def execute(datas, parent):
|
||||
result = {}
|
||||
|
||||
for plugin in os.listdir(PLUGINS_PATH):
|
||||
module = os.path.splitext(plugin)[0]
|
||||
try:
|
||||
module = imp.load_module(module, *imp.find_module(module, [PLUGINS_PATH]))
|
||||
for name, func in module.get_plugins(datas['model']):
|
||||
result[name] = func
|
||||
except Exception, exception:
|
||||
print exception
|
||||
continue
|
||||
if not result:
|
||||
common.message(_('No available plugin for this resource!'), parent)
|
||||
return False
|
||||
res = common.selection(_('Choose a Plugin'), result, parent, alwaysask=True)
|
||||
if res:
|
||||
res[1](datas, parent)
|
||||
return True
|
||||
@@ -0,0 +1,19 @@
|
||||
from tryton.action import Action
|
||||
|
||||
def workflow_print(datas, parent):
|
||||
datas = datas.copy()
|
||||
datas['nested'] = False
|
||||
Action.exec_report('workflow.instance.graph', datas)
|
||||
return True
|
||||
|
||||
def workflow_print_complex(datas, parent):
|
||||
datas = datas.copy()
|
||||
datas['nested'] = True
|
||||
Action.exec_report('workflow.instance.graph', datas)
|
||||
return True
|
||||
|
||||
def get_plugins(model):
|
||||
return [
|
||||
(_('Print Workflow'), workflow_print),
|
||||
(_('Print Workflow (Complex)'), workflow_print_complex),
|
||||
]
|
||||
Reference in new issue
Block a user