diff options
| author | Jean-Baptiste Aubort <jean-baptiste.aubort@camptocamp.com> | 2008-08-29 10:52:04 +0200 |
|---|---|---|
| committer | Jean-Baptiste Aubort <jean-baptiste.aubort@camptocamp.com> | 2008-08-29 10:52:04 +0200 |
| commit | 5fc89eae6b7aacc0b3457910fb9a42aa805ca39b (patch) | |
| tree | 40e2d722382b3688434e48dd420e91ff6fbf543b /addons/base_module_record | |
| parent | 43122ed70852d9f28c69db6296e36dd2dd1b4e92 (diff) | |
| parent | ae21cdb0eeaa8df585a2f1316935223d84ff3fe5 (diff) | |
merge with #1527 trunk
bzr revid: jean-baptiste.aubort@camptocamp.com-20080829085204-0fi6v6wfnescqy3a
Diffstat (limited to 'addons/base_module_record')
| -rw-r--r-- | addons/base_module_record/__init__.py | 33 | ||||
| -rw-r--r-- | addons/base_module_record/__terp__.py | 34 | ||||
| -rw-r--r-- | addons/base_module_record/base_module_record.py | 234 | ||||
| -rw-r--r-- | addons/base_module_record/base_module_record_wizard.xml | 45 | ||||
| -rw-r--r-- | addons/base_module_record/wizard/__init__.py | 32 | ||||
| -rw-r--r-- | addons/base_module_record/wizard/base_module_record.py | 116 | ||||
| -rw-r--r-- | addons/base_module_record/wizard/base_module_save.py | 196 |
7 files changed, 690 insertions, 0 deletions
diff --git a/addons/base_module_record/__init__.py b/addons/base_module_record/__init__.py new file mode 100644 index 00000000000..e7a1641507b --- /dev/null +++ b/addons/base_module_record/__init__.py @@ -0,0 +1,33 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# Fabien Pinckaers <fp@tiny.Be> +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import base_module_record +import wizard +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/base_module_record/__terp__.py b/addons/base_module_record/__terp__.py new file mode 100644 index 00000000000..cb5754af64a --- /dev/null +++ b/addons/base_module_record/__terp__.py @@ -0,0 +1,34 @@ +# -*- encoding: utf-8 -*- +{ + "name" : "Module Recorder", + "version" : "1.0", + "author" : "Tiny", + "website" : "http://tinyerp.com", + "category" : "Generic Modules/Base", + "description": """ +This module allows you to create a new module without any development. +It records all operations on objects during the recording session and +produce a .ZIP module. So you can create your own module directly from +the Tiny ERP client. + +This version works for creating and updating existing records. It recomputes +dependencies and links for all types of widgets (many2one, many2many, ...). +It also support workflows and demo/update data. + +This should help you to easily create reuseable and publishable modules +for custom configurations and demo/testing data. + +How to use it: +1. Start the recording +2. Do stuff in your Tiny ERP client +3. Stop the recording session +4. Export to a reusable module + """, + "depends" : ["base"], + "init_xml" : [ ], + "demo_xml" : [ ], + "update_xml" : [ "base_module_record_wizard.xml" ], + "installable": True +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/base_module_record/base_module_record.py b/addons/base_module_record/base_module_record.py new file mode 100644 index 00000000000..6c130549f64 --- /dev/null +++ b/addons/base_module_record/base_module_record.py @@ -0,0 +1,234 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# Fabien Pinckaers <fp@tiny.Be> +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +from xml.dom import minidom +from osv import fields,osv +import netsvc +import pooler +import string + +class base_module_record(osv.osv): + _name = "ir.module.record" + _columns = { + + } + def __init__(self, pool, cr=None): + if super(base_module_record, self).__init__.func_code.co_argcount ==3: + super(base_module_record, self).__init__(pool,cr) + else: + super(base_module_record, self).__init__(pool) + self.recording = 0 + self.recording_data = [] + self.depends = {} + + # To Be Improved + def _create_id(self, cr, uid, model, data): + i = 0 + while True: + name = filter(lambda x: x in string.letters, (data.get('name','') or '').lower()) + val = model.replace('.','_')+'_'+name+ str(i) + i+=1 + if val not in self.ids.values(): + break + return val + + def _get_id(self, cr, uid, model, id): + if (model,id) in self.ids: + return self.ids[(model,id)], False + dt = self.pool.get('ir.model.data') + dtids = dt.search(cr, uid, [('model','=',model), ('res_id','=',id)]) + if not dtids: + return None, None + obj = dt.browse(cr, uid, dtids[0]) + self.depends[obj.module] = True + return obj.module+'.'+obj.name, obj.noupdate + + def _create_record(self, cr, uid, doc, model, data, record_id, noupdate=False): + record = doc.createElement('record') + record.setAttribute("id", record_id) + record.setAttribute("model", model) + lids = self.pool.get('ir.model.data').search(cr, uid, [('model','=',model)]) + res = self.pool.get('ir.model.data').read(cr, uid, lids[:1], ['module']) + if res: + self.depends[res[0]['module']]=True + record_list = [record] + fields = self.pool.get(model).fields_get(cr, uid) + for key,val in data.items(): + if not (val or (fields[key]['type']=='boolean')): + continue + if fields[key]['type'] in ('integer','float'): + field = doc.createElement('field') + field.setAttribute("name", key) + field.setAttribute("eval", val and str(val) or 'False' ) + record.appendChild(field) + elif fields[key]['type'] in ('boolean',): + field = doc.createElement('field') + field.setAttribute("name", key) + field.setAttribute("eval", val and '1' or '0' ) + record.appendChild(field) + elif fields[key]['type'] in ('many2one',): + field = doc.createElement('field') + field.setAttribute("name", key) + if type(val) in (type(''),type(u'')): + id = val + else: + id,update = self._get_id(cr, uid, fields[key]['relation'], val) + noupdate = noupdate or update + if not id: + field.setAttribute("model", fields[key]['relation']) + name = self.pool.get(fields[key]['relation']).browse(cr, uid, val).name + print name + field.setAttribute("search", "[('name','=','"+name+"')]") + else: + field.setAttribute("ref", id) + record.appendChild(field) + elif fields[key]['type'] in ('one2many',): + for valitem in (val or []): + if valitem[0]==0: + fname = self.pool.get(model)._columns[key]._fields_id + valitem[2][fname] = record_id + newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) + childrecord, update = self._create_record(cr, uid, doc, fields[key]['relation'],valitem[2], newid) + noupdate = noupdate or update + record_list += childrecord + self.ids[(fields[key]['relation'],newid)] = newid + else: + pass + elif fields[key]['type'] in ('many2many',): + res = [] + for valitem in (val or []): + if valitem[0]==6: + for id2 in valitem[2]: + id,update = self._get_id(cr, uid, fields[key]['relation'], id2) + self.ids[(fields[key]['relation'],id)] = id + noupdate = noupdate or update + res.append(id) + field = doc.createElement('field') + field.setAttribute("name", key) + field.setAttribute("eval", "[(6,0,["+','.join(map(lambda x: "ref('%s')" % (x,), res))+'])]') + record.appendChild(field) + else: + field = doc.createElement('field') + field.setAttribute("name", key) + + if not isinstance(val, basestring): + val = str(val) + + val = val and ('"""%s"""' % val.replace('\\', '\\\\').replace('"', '\"')) or 'False' + if isinstance(val, basestring): + val = val.decode('utf8') + + field.setAttribute(u"eval", val) + record.appendChild(field) + return record_list, noupdate + + def _generate_object_xml(self, cr, uid, rec, recv, doc, result=None): + record_list = [] + noupdate = False + if rec[4]=='write': + for id in rec[5]: + id,update = self._get_id(cr, uid, rec[3], id) + noupdate = noupdate or update + if not id: + continue + record,update = self._create_record(cr, uid, doc, rec[3], rec[6], id) + noupdate = noupdate or update + record_list += record + elif rec[4]=='create': + id = self._create_id(cr, uid, rec[3],rec[5]) + record,noupdate = self._create_record(cr, uid, doc, rec[3], rec[5], id) + self.ids[(rec[3],result)] = id + record_list += record + return record_list,noupdate + def _generate_assert_xml(self, rec, doc): + pass + def generate_xml(self, cr, uid): + # Create the minidom document + self.ids = {} + doc = minidom.Document() + terp = doc.createElement("terp") + doc.appendChild(terp) + for rec in self.recording_data: + if rec[0]=='workflow': + rec_id,noupdate = self._get_id(cr, uid, rec[1][3], rec[1][5]) + if not rec_id: + continue + data = doc.createElement("data") + terp.appendChild(data) + wkf = doc.createElement('workflow') + data.appendChild(wkf) + wkf.setAttribute("model", rec[1][3]) + wkf.setAttribute("action", rec[1][4]) + if noupdate: + data.setAttribute("noupdate", "1") + wkf.setAttribute("ref", rec_id) + if rec[0]=='query': + res_list,noupdate = self._generate_object_xml(cr, uid, rec[1], rec[2], doc, rec[3]) + data = doc.createElement("data") + if noupdate: + data.setAttribute("noupdate", "1") + if res_list: + terp.appendChild(data) + for res in res_list: + data.appendChild(res) + elif rec[0]=='assert': + pass + res = doc.toprettyxml(indent="\t") + return doc.toprettyxml(indent="\t").encode('utf8') +base_module_record() + +def fnct_call(fnct): + def execute(*args, **argv): + res = fnct(*args, **argv) + pool = pooler.get_pool(args[0]) + mod = pool.get('ir.module.record') + if mod and mod.recording: + if args[4] not in ('default_get','read','fields_view_get','fields_get','search','name_search','name_get','get','request_get', 'get_sc'): + mod.recording_data.append(('query', args, argv,res)) + return res + return execute + +def fnct_call_workflow(fnct): + def exec_workflow(*args, **argv): + res = fnct(*args, **argv) + pool = pooler.get_pool(args[0]) + mod = pool.get('ir.module.record') + if mod and mod.recording: + mod.recording_data.append(('workflow', args, argv)) + return res + return exec_workflow + +obj = netsvc._service['object'] +obj.execute = fnct_call(obj.execute) +obj.exportMethod(obj.execute) +obj.exec_workflow = fnct_call_workflow(obj.exec_workflow) +obj.exportMethod(obj.exec_workflow) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/base_module_record/base_module_record_wizard.xml b/addons/base_module_record/base_module_record_wizard.xml new file mode 100644 index 00000000000..b98d4f0479e --- /dev/null +++ b/addons/base_module_record/base_module_record_wizard.xml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<terp> + <data> + <wizard + id="wizard_base_module_record" + string="Record module" + model="ir.module.module" + multi="True" + name="base_module_record.module_record"/> + + <menuitem + parent="base.menu_management" + name="Module Recording" + id="menu_wizard_base_mod_rec"/> + <menuitem + parent="menu_wizard_base_mod_rec" + name="Start Recording" + type="wizard" + action="wizard_base_module_record" + id="menu_wizard_base_module_record"/> + + <menuitem + parent="menu_wizard_base_mod_rec" + name="Stop Recording" + type="wizard" + action="wizard_base_module_record" + id="menu_wizard_base_module_record_stop"/> + + + <wizard + id="wizard_base_module_save" + string="Save Recorded Module" + model="ir.module.module" + multi="True" + name="base_module_record.module_save"/> + + <menuitem + parent="menu_wizard_base_mod_rec" + name="Save Recorded Module" + type="wizard" + action="wizard_base_module_save" + id="menu_wizard_base_module_save"/> + + </data> +</terp> diff --git a/addons/base_module_record/wizard/__init__.py b/addons/base_module_record/wizard/__init__.py new file mode 100644 index 00000000000..4e8cd690285 --- /dev/null +++ b/addons/base_module_record/wizard/__init__.py @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import base_module_record +import base_module_save +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/base_module_record/wizard/base_module_record.py b/addons/base_module_record/wizard/base_module_record.py new file mode 100644 index 00000000000..421caafb7a2 --- /dev/null +++ b/addons/base_module_record/wizard/base_module_record.py @@ -0,0 +1,116 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import wizard +import osv +import pooler + +intro_stop_form = '''<?xml version="1.0"?> +<form string="Module Recording"> + <separator string="Recording Information" colspan="4"/> + <label string="Tiny ERP recording is stopped. Don't forget to save the recorded module." colspan="4" align="0.0"/> + <label string="You can continue the recording session by relauching the 'start recording' wizard." colspan="4" align="0.0"/> +</form>''' + +intro_start_form = '''<?xml version="1.0"?> +<form string="Recording Stopped"> + <separator string="Recording information" colspan="4"/> + <label string="The module recorder allows you to record every operation made in the Tiny ERP client and save them as a module. You will be able to install this module on any database to reuse and/or publish it." colspan="4" align="0.0"/> + <field name="continue"/> +</form>''' + +intro_start_fields = { + 'continue': {'string':'Continue Previous Session', 'type':'boolean'} +} + +def _stop_recording(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + mod = pool.get('ir.module.record') + mod.recording = 0 + return {} + +def _start_recording(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + mod = pool.get('ir.module.record') + mod.recording = 1 + if not data['form']['continue']: + mod.recording_data = [] + mod.depends = {} + return {} + +def _check_recording(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + mod = pool.get('ir.module.record') + if mod.recording: + return 'stop' + return 'start' + +class base_module_publish(wizard.interface): + states = { + 'init': { + 'actions': [], + 'result': { + 'type':'choice', + 'next_state':_check_recording, + } + }, + 'start': { + 'actions': [], + 'result': { + 'type':'form', + 'arch':intro_start_form, + 'fields': intro_start_fields, + 'state':[ + ('end', 'Cancel', 'gtk-cancel'), + ('start_confirm', 'Start Recording', 'gtk-ok'), + ] + } + }, + 'start_confirm': { + 'actions': [_start_recording], + 'result': { + 'type':'state', + 'state': 'end' + } + }, + 'stop': { + 'actions': [_stop_recording], + 'result': { + 'type':'form', + 'arch':intro_stop_form, + 'fields': {}, + 'state':[ + ('end', 'Continue', 'gtk-ok'), + ] + } + } + } +base_module_publish('base_module_record.module_record') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/base_module_record/wizard/base_module_save.py b/addons/base_module_record/wizard/base_module_save.py new file mode 100644 index 00000000000..1b26c34ea65 --- /dev/null +++ b/addons/base_module_record/wizard/base_module_save.py @@ -0,0 +1,196 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import wizard +import osv +import pooler + +info_start_form = '''<?xml version="1.0"?> +<form string="Module Recording"> + <separator string="Recording Information" colspan="4"/> + <field name="info_status"/> + <field name="info_text" colspan="4" nolabel="1"/> +</form>''' + +info_start_fields = { + 'info_text': {'string':'Information', 'type':'text', 'readonly':True}, + 'info_status': {'string':'Status','type':'selection', 'selection':[('no','Not Recording'),('record','Recording')], 'readonly':True} +} + + + +intro_start_form = '''<?xml version="1.0"?> +<form string="Module Recording"> + <separator string="Module Information" colspan="4"/> + <field name="name"/> + <field name="directory_name"/> + <field name="version"/> + <field name="author"/> + <field name="website" colspan="4"/> + <field name="category" colspan="4"/> + <field name="data_kind"/> + <newline/> + <field name="description" colspan="4"/> +</form>''' + +intro_start_fields = { + 'name': {'string':'Module Name', 'type':'char', 'size':64, 'required':True}, + 'directory_name': {'string':'Directory Name', 'type':'char', 'size':32, 'required':True}, + 'version': {'string':'Version', 'type':'char', 'size':16, 'required':True}, + 'author': {'string':'Author', 'type':'char', 'size':64, 'default': lambda *args: 'Tiny', 'required':True}, + 'category': {'string':'Category', 'type':'char', 'size':64, 'default': lambda *args: 'Vertical Modules/Parametrization', 'required':True}, + 'website': {'string':'Documentation URL', 'type':'char', 'size':64, 'default': lambda *args: 'http://tinyerp.com', 'required':True}, + 'description': {'string':'Full Description', 'type':'text', 'required':True}, + 'data_kind': {'string':'Type of Data', 'type':'selection', 'selection':[('demo','Demo Data'),('update','Normal Data')], 'required':True, 'default': lambda *args:'update'}, +} + +intro_save_form = '''<?xml version="1.0"?> +<form string="Module Recording"> + <separator string="Module successfully created !" colspan="4"/> + <field name="module_filename"/> + <newline/> + <field name="module_file"/> + <separator string="Information" colspan="4"/> + <label string="If you think your module could interrest others people, we'd like you to publish it on TinyERP.com, in the 'Modules' section. You can do it through the website or using features of the 'base_module_publish' module." colspan="4" align="0.0"/> + <label string="Thanks in advance for your contribution." colspan="4" align="0.0"/> +</form>''' + +intro_save_fields = { + 'module_file': {'string': 'Module .zip File', 'type':'binary', 'readonly':True}, + 'module_filename': {'string': 'Filename', 'type':'char', 'size': 64, 'readonly':True}, +} + +import zipfile +import StringIO +import base64 + +def _info_default(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + mod = pool.get('ir.module.record') + result = {} + info = "Details of "+str(len(mod.recording_data))+" Operation(s):\n\n" + for line in mod.recording_data: + result.setdefault(line[0],{}) + result[line[0]].setdefault(line[1][3], {}) + result[line[0]][line[1][3]].setdefault(line[1][4], 0) + result[line[0]][line[1][3]][line[1][4]]+=1 + for key1,val1 in result.items(): + info+=key1+"\n" + for key2,val2 in val1.items(): + info+="\t"+key2+"\n" + for key3,val3 in val2.items(): + info+="\t\t"+key3+" : "+str(val3)+"\n" + return {'info_text': info, 'info_status':mod.recording and 'record' or 'no'} + +def _create_module(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + mod = pool.get('ir.module.record') + res_xml = mod.generate_xml(cr, uid) + + s=StringIO.StringIO() + zip = zipfile.ZipFile(s, 'w') + dname = data['form']['directory_name'] + data['form']['update_name'] = '' + data['form']['demo_name'] = '' + if data['form']['data_kind'] =='demo': + data['form']['demo_name'] = '"%(directory_name)s_data.xml"' % data['form'] + else: + data['form']['update_name'] = '"%(directory_name)s_data.xml"' % data['form'] + data['form']['depends'] = ','.join(map(lambda x: '"'+x+'"',mod.depends.keys())) + _terp = """{ + "name" : "%(name)s", + "version" : "%(version)s", + "author" : "%(author)s", + "website" : "%(website)s", + "category" : "%(category)s", + "description": \"\"\"%(description)s\"\"\", + "depends" : [%(depends)s], + "init_xml" : [ ], + "demo_xml" : [ %(demo_name)s], + "update_xml" : [%(update_name)s], + "installable": True +} """ % data['form'] + filewrite = { + '__init__.py':'#\n# Generated by the Tiny ERP module recorder !\n#\n', + '__terp__.py':_terp, + dname+'_data.xml': res_xml + } + for name,datastr in filewrite.items(): + info = zipfile.ZipInfo(dname+'/'+name) + info.compress_type = zipfile.ZIP_DEFLATED + info.external_attr = 2175008768 + zip.writestr(info, datastr) + zip.close() + print data['form'] + return { + 'module_file': base64.encodestring(s.getvalue()), + 'module_filename': data['form']['directory_name']+'-'+data['form']['version']+'.zip' + } + +class base_module_publish(wizard.interface): + states = { + 'init': { + 'actions': [_info_default], + 'result': { + 'type':'form', + 'arch':info_start_form, + 'fields': info_start_fields, + 'state':[ + ('end', 'Cancel', 'gtk-cancel'), + ('info', 'Continue', 'gtk-ok'), + ] + } + }, + 'info': { + 'actions': [], + 'result': { + 'type':'form', + 'arch':intro_start_form, + 'fields': intro_start_fields, + 'state':[ + ('end', 'Cancel', 'gtk-cancel'), + ('save', 'Continue', 'gtk-ok'), + ] + } + }, + 'save': { + 'actions': [_create_module], + 'result': { + 'type':'form', + 'arch':intro_save_form, + 'fields': intro_save_fields, + 'state':[ + ('end', 'Close', 'gtk-ok'), + ] + } + } + } +base_module_publish('base_module_record.module_save') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + |
