export language: use orm_memory
bzr revid: chs@tinyerp.com-3b3b231127a3d54e5b7b8a6b35e81e166c417536
This commit is contained in:
parent
ff7f923855
commit
4864df6759
|
@ -51,7 +51,6 @@
|
|||
"module/module_wizard.xml",
|
||||
"module/module_view.xml",
|
||||
"module/module_report.xml",
|
||||
# "module/move_module_wizard.xml",
|
||||
"res/res_request_view.xml",
|
||||
"res/res_lang_view.xml",
|
||||
"res/partner/partner_report.xml",
|
||||
|
|
|
@ -21,13 +21,41 @@
|
|||
<field name="wiz_name">module.lang.install</field>
|
||||
</record>
|
||||
<menuitem action="wizard_lang_install" id="menu_wizard_lang_install" parent="base.menu_translation" type="wizard"/>
|
||||
|
||||
<record id="wizard_lang_export" model="ir.actions.wizard">
|
||||
<field name="name">Export language</field>
|
||||
<field name="wiz_name">module.lang.export</field>
|
||||
|
||||
<record id="wizard_lang_export" model="ir.ui.view">
|
||||
<field name="name">Export Language</field>
|
||||
<field name="model">wizard.module.lang.export</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form col="4" string="Export language">
|
||||
<image name="gtk-dialog-info"/>
|
||||
<group col="2" states="choose">
|
||||
<separator string="Export translation file" colspan="2"/>
|
||||
<label align="0.0" string="Choose a language to export:"/>
|
||||
<field name="lang" nolabel="1"/>
|
||||
<button icon="gtk-cancel" name="act_cancel" special="cancel" string="Cancel" type="object"/>
|
||||
<button icon="gtk-ok" name="act_getfile" string="Get file" type="object"/>
|
||||
</group>
|
||||
<group col="1" states="get">
|
||||
<separator string="Export done" colspan="1"/>
|
||||
<field name="data" readonly="1"/>
|
||||
<label string="Save this document to a .CSV file and open it with your favourite spreadsheet software. The file encoding is UTF-8. You have to translate the latest column before reimporting it."/>
|
||||
<button icon="gtk-close" name="act_destroy" special="cancel" string="Close" type="object"/>
|
||||
</group>
|
||||
<field name="state" readonly="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<menuitem action="wizard_lang_export" id="menu_wizard_lang_export" parent="base.menu_translation" type="wizard"/>
|
||||
|
||||
<record id="action_wizard_lang_export" model="ir.actions.act_window">
|
||||
<field name="name">Export language</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">wizard.module.lang.export</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
<menuitem action="action_wizard_lang_export" id="menu_wizard_lang_export" parent="base.menu_translation"/>
|
||||
|
||||
<record id="wizard_lang_import" model="ir.actions.wizard">
|
||||
<field name="name">Import language</field>
|
||||
<field name="wiz_name">module.lang.import</field>
|
||||
|
@ -35,4 +63,4 @@
|
|||
<menuitem action="wizard_lang_import" id="menu_wizard_lang_import" parent="base.menu_translation" type="wizard"/>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
</terp>
|
||||
|
|
|
@ -35,6 +35,9 @@ import StringIO
|
|||
import csv
|
||||
import pooler
|
||||
|
||||
from osv import fields,osv
|
||||
|
||||
'''
|
||||
view_form_init="""<?xml version="1.0"?>
|
||||
<form string="Export language">
|
||||
<image name="gtk-dialog-info" colspan="2"/>
|
||||
|
@ -100,3 +103,56 @@ class wizard_export_lang(wizard.interface):
|
|||
},
|
||||
}
|
||||
wizard_export_lang('module.lang.export')
|
||||
'''
|
||||
|
||||
class wizard_export_lang(osv.osv_memory):
|
||||
|
||||
def _get_languages(self, cr, uid, context):
|
||||
lang_obj=pooler.get_pool(cr.dbname).get('res.lang')
|
||||
ids=lang_obj.search(cr, uid, [('active', '=', True),])
|
||||
langs=lang_obj.browse(cr, uid, ids)
|
||||
return [(lang.code, lang.translatable and lang.name or _('New language')) for lang in langs]
|
||||
|
||||
|
||||
def act_cancel(self, cr, uid, ids, context=None):
|
||||
#self.unlink(cr, uid, ids, context)
|
||||
return {'type':'ir.actions.act_window_close' }
|
||||
|
||||
def act_destroy(self, *args):
|
||||
return {'type':'ir.actions.act_window_close' }
|
||||
|
||||
def act_getfile(self, cr, uid, ids, context=None):
|
||||
print "get filE"
|
||||
this = self.browse(cr, uid, ids)[0]
|
||||
print this.lang
|
||||
# set the data
|
||||
file=tools.trans_generate(this.lang, 'all', dbname=cr.dbname)
|
||||
buf=StringIO.StringIO()
|
||||
writer=csv.writer(buf, 'UNIX')
|
||||
for row in file:
|
||||
writer.writerow(row)
|
||||
del file
|
||||
out=base64.encodestring(buf.getvalue())
|
||||
buf.close()
|
||||
|
||||
self.write(cr, uid, ids, {'state':'get','data':out}, context=context)
|
||||
|
||||
return {
|
||||
'view_type': 'form',
|
||||
"view_mode": 'form',
|
||||
'res_model': self._name,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target':'new',
|
||||
}
|
||||
|
||||
_name = "wizard.module.lang.export"
|
||||
_columns = {
|
||||
'lang': fields.selection(_get_languages, 'Language',required=True),
|
||||
'data': fields.binary('File', readonly=True),
|
||||
'state': fields.selection( ( ('choose','choose'), # choose language
|
||||
('get','get'), # get the file
|
||||
#('end','end'), # virtual state: unlink self
|
||||
) ),
|
||||
}
|
||||
_defaults = { 'state': lambda *a: 'choose', }
|
||||
wizard_export_lang()
|
||||
|
|
Loading…
Reference in New Issue