File: __init__.py

package info (click to toggle)
tinyerp-client 3.4.2-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,832 kB
  • ctags: 1,024
  • sloc: python: 7,566; sh: 2,253; makefile: 81
file content (26 lines) | stat: -rw-r--r-- 847 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import common
import re

import workflow_print

plugins_repository = {
	'workflow_print_simple': {'model':'.*', 'string':'Print Workflow', 'action': workflow_print.wkf_print_simple },
	'workflow_print': {'model':'.*', 'string':'Print Workflow (Complex)', 'action': workflow_print.wkf_print },
}

def execute(datas):
	result = {}
	for p in plugins_repository:
		if not 'model_re' in plugins_repository[p]:
			plugins_repository[p]['model_re'] = re.compile(plugins_repository[p]['model'])
		res = plugins_repository[p]['model_re'].search(datas['model'])
		if res:
			result[plugins_repository[p]['string']] = p
	if not len(result):
		common.message(_('No available plugin for this resource !'))
		return False
	sel = common.selection(_('Choose a Plugin'), result, alwaysask=True)
	if sel:
		plugins_repository[sel[1]]['action'](datas)
	return True