[MERGE]: Merged with team branch.

bzr revid: uco@tinyerp.com-20100901103021-9hk9c4963xa293xz
This commit is contained in:
uco (Open ERP)
2010-09-01 16:00:21 +05:30
22 changed files with 790 additions and 523 deletions
+9 -2
View File
@@ -48,21 +48,28 @@
'module/module_web_view.xml',
'module/module_data.xml',
'module/module_report.xml',
'module/wizard/base_module_import_view.xml',
'module/wizard/base_module_update_view.xml',
'module/wizard/base_language_install_view.xml',
'res/res_request_view.xml',
'res/res_lang_view.xml',
'res/res_log_view.xml',
'res/partner/partner_report.xml',
'res/partner/partner_view.xml',
'res/partner/partner_wizard.xml',
'res/bank_view.xml',
'res/country_view.xml',
'res/res_currency_view.xml',
'res/res_currency_view.xml',
'res/partner/crm_view.xml',
'res/partner/wizard/partner_sms_send_view.xml',
'res/partner/wizard/partner_wizard_spam_view.xml',
'res/partner/wizard/partner_clear_ids_view.xml',
'res/partner/wizard/partner_wizard_ean_check_view.xml',
'res/partner/partner_data.xml',
'res/ir_property_view.xml',
'security/base_security.xml',
'maintenance/maintenance_view.xml',
'security/ir.model.access.csv'
],
-19
View File
@@ -1,30 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="wizard_base_module_import" model="ir.actions.wizard">
<field name="name">Import module</field>
<field name="wiz_name">base.module.import</field>
</record>
<menuitem action="wizard_base_module_import" id="menu_wizard_module_import" parent="menu_management" type="wizard"/>
<record id="wizard_update" model="ir.actions.wizard">
<field name="name">Update Modules List</field>
<field name="wiz_name">module.module.update</field>
</record>
<menuitem action="wizard_update" icon="STOCK_CONVERT" id="menu_module_update" parent="menu_management" type="wizard"/>
<wizard id="wizard_upgrade" model="ir.module.module" name="module.upgrade" string="Apply Scheduled Upgrades"/>
<menuitem action="wizard_upgrade" id="menu_wizard_upgrade" parent="menu_management" type="wizard"/>
<record id="wizard_lang_install" model="ir.actions.wizard">
<field name="name">Load an Official Translation</field>
<field name="wiz_name">module.lang.install</field>
</record>
<menuitem action="wizard_lang_install" id="menu_wizard_lang_install" parent="menu_translation" type="wizard"/>
<record id="wizard_lang_export" model="ir.ui.view">
<field name="name">Export a Translation File</field>
<field name="model">wizard.module.lang.export</field>
+6 -5
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@@ -15,19 +15,20 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard_update_module
import wizard_module_upgrade
import wizard_configuration
import wizard_module_lang_install
import add_new
import wizard_export_lang
import wizard_import_lang
import wizard_module_import
import wizard_update_translations
import base_module_import
import base_module_update
import base_language_install
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import tools
import pooler
from osv import osv, fields
class base_language_install(osv.osv_memory):
""" Install Language"""
_name = "base.language.install"
_description = "Install Language"
_columns = {
'lang': fields.selection(tools.scan_languages(),'Language'),
}
def lang_install(self, cr, uid, ids, context):
language_obj = self.browse(cr, uid, ids)[0]
lang = language_obj.lang
if lang:
modobj = self.pool.get('ir.module.module')
mids = modobj.search(cr, uid, [('state', '=', 'installed')])
modobj.update_translations(cr, uid, mids, lang)
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_language_install_msg')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.import.msg',
'views': [(id2, 'form')],
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
base_language_install()
class base_language_install_msg(osv.osv_memory):
""" Install Language"""
_name = "base.language.install.msg"
_description = "Install Language"
base_language_install_msg()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_base_language_install" model="ir.ui.view">
<field name="name">Install Language</field>
<field name="model">base.language.install</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="System Upgrade">
<group colspan="2" col="4">
<separator string="System Upgrade" colspan="6"/>
<newline/>
<label align="0.0" string="Choose a language to install:" colspan="4"/>
<field name="lang" colspan="4"/>
<label align="0.0" string="Note that this operation may take a few minutes." colspan="4"/>
<separator string="" colspan="6"/>
<button special="cancel" string="Close" icon="gtk-cancel"/>
<button name="lang_install" string="Start installation" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_language_install" model="ir.actions.act_window">
<field name="name">Install Language</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base.language.install</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Load an Official Translation"
action="action_view_base_language_install"
id="menu_view_base_language_install"
parent="menu_translation"/>
<record id="view_base_language_install_msg" model="ir.ui.view">
<field name="name">Install Language Message</field>
<field name="model">base.module.import.msg</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Language file loaded.">
<group colspan="2" col="4">
<separator string="Installation Done" colspan="4"/>
<label align="0.0" string="The selected language has been successfully installed.\nYou must change the preferences of the user and open a new menu to view changes." colspan="4"/>
<separator string="" colspan="4"/>
<button special="cancel" string="OK" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_language_install_msg" model="ir.actions.act_window">
<field name="name">Install Language Message</field>
<field name="res_model">base.module.import.msg</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_base_language_install"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,116 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pooler
import os
import tools
import zipfile
from StringIO import StringIO
import base64
from tools.translate import _
from osv import osv, fields
class base_module_import(osv.osv_memory):
""" Import Module """
_name = "base.module.import"
_description = "Import Module"
_columns = {
'module_file': fields.binary('Module .ZIP file', required=True),
}
def importzip(self, cr, uid, ids, context):
module_obj= self.pool.get('ir.module.module')
active_ids = context and context.get('active_ids', False)
data = self.browse(cr, uid, ids , context=context)[0]
module_data = data.module_file
val =base64.decodestring(module_data)
fp = StringIO()
fp.write(val)
fdata = zipfile.ZipFile(fp, 'r')
fname = fdata.namelist()[0]
module_name = os.path.split(fname)[0]
ad = tools.config['addons_path']
fname = os.path.join(ad,module_name+'.zip')
try:
fp = file(fname, 'wb')
fp.write(val)
fp.close()
except IOError, e:
raise osv.except_osv(_('Error !'), _('Can not create the module file: %s !') % (fname,) )
module_obj.update_list(cr, uid,{'module_name': module_name,})
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_import_msg')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
module_name = module_obj.browse(cr, uid, ids, context=context)
return {
'domain': str([('name', '=', module_name)]),
'name': 'Message',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.import.msg',
'views': [(id2, 'form')],
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
base_module_import()
class base_module_import_msg(osv.osv_memory):
""" message """
_name = "base.module.import.msg"
_description = "Message"
def action_module_open(self, cr, uid, ids, context):
module_obj = self.pool.get('base.module.import')
data = module_obj.browse(cr, uid, ids , context=context)[0]
module_data = data.module_file
val =base64.decodestring(module_data)
fp = StringIO()
fp.write(val)
fdata = zipfile.ZipFile(fp, 'r')
fname = fdata.namelist()[0]
module_name = os.path.split(fname)[0]
return {
'domain': str([('name', '=', module_name)]),
'name': 'Module List',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'ir.module.module',
'type': 'ir.actions.act_window',
}
base_module_import_msg()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_base_module_import" model="ir.ui.view">
<field name="name">Module Import</field>
<field name="model">base.module.import</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Module import">
<separator string="Module Import" colspan="4"/>
<label string="Please give your module .ZIP file to import." colspan="4"/>
<field name="module_file"/>
<separator string="" colspan="4" />
<newline/>
<group colspan="6" >
<button special="cancel" string="Close" icon="gtk-cancel"/>
<button name="importzip" string="Import module" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_module_import" model="ir.actions.act_window">
<field name="name">Module Import</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base.module.import</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name="Import Module"
action="action_view_base_module_import"
id="menu_view_base_module_import"
parent="menu_management"
sequence="1"/>
<record id="view_base_module_import_msg" model="ir.ui.view">
<field name="name">Module Import Message</field>
<field name="model">base.module.import.msg</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Message">
<label string="Module successfully imported !"/>
<separator string="" colspan="4"/>
<newline/>
<group>
<button name="action_module_open" string="Close" type="object" icon="gtk-cancel"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_module_import_msg" model="ir.actions.act_window">
<field name="name">Module Import Message</field>
<field name="res_model">base.module.import.msg</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_base_module_import"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,111 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import netsvc
import pooler
from osv import osv, fields
class base_module_update(osv.osv_memory):
""" Update Module """
_name = "base.module.update"
_description = "Update Module"
def update_module(self, cr, uid, ids, context):
"""
Update Module
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
"""
data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_update_open')
if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'base.module.update.open',
'views': [(id2, 'form')],
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
base_module_update()
class base_module_update_open(osv.osv_memory):
""" Update Module Open """
_name = "base.module.update.open"
_description = "Update Module Open"
def default_get(self, cr, uid, fields, context=None):
"""
This function gets default values
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param fields: List of fields for default value
@param context: A standard dictionary for contextual values
@return : default values of fields.
"""
module_obj = self.pool.get('ir.module.module')
update, add = module_obj.update_list(cr, uid,)
return {'update': update, 'add': add}
_columns = {
'update': fields.integer('Number of modules updated', readonly=True),
'add': fields.integer('Number of modules added', readonly=True),
}
def action_module_open(self, cr, uid, ids, context):
"""
Update Module List Open
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
"""
res = {
'domain': str([]),
'name': 'Module List',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'ir.module.module',
'view_id': False,
'type': 'ir.actions.act_window',
}
view_obj = self.pool.get('ir.ui.view')
search_view_id = view_obj.search(cr, uid, [('name','=','ir.module.module.list.select')], context=context)
if search_view_id:
res.update({'search_view_id' : search_view_id[0]})
return res
base_module_update_open()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_base_module_update" model="ir.ui.view">
<field name="name">Module Update</field>
<field name="model">base.module.update</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Scan for new modules">
<label string="This function will check for new modules in the 'addons' path" colspan="4" align="0.0"/>
<separator string="" colspan="4" />
<newline/>
<group colspan="6" >
<button special="cancel" string="Close" icon="gtk-cancel"/>
<button name="update_module" string="Check new modules" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_module_update" model="ir.actions.act_window">
<field name="name">Module Update</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base.module.update</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
name=" Update Modules List"
action="action_view_base_module_update"
id="menu_view_base_module_update"
parent="menu_management"
sequence="2"
icon="STOCK_CONVERT"/>
<record id="view_base_module_update_open" model="ir.ui.view">
<field name="name">Update ModuleList</field>
<field name="model">base.module.update.open</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="New modules">
<field name="update" colspan="4"/>
<field name="add" colspan="4"/>
<separator string="" colspan="4" />
<newline/>
<group colspan="6" >
<button special="cancel" string="Close" icon="gtk-cancel"/>
<button name="action_module_open" string="OK" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_base_module_update_open" model="ir.actions.act_window">
<field name="name">Update ModuleList</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">base.module.update.open</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_base_module_update"/>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -1,118 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import osv
import pooler
import os
import tools
import zipfile
from StringIO import StringIO
import base64
from tools.translate import _
finish_form ='''<?xml version="1.0"?>
<form string="Module import">
<label string="Module successfully imported !" colspan="4"/>
</form>
'''
ask_form ='''<?xml version="1.0"?>
<form string="Module import">
<separator string="Module Import" colspan="4"/>
<label string="Please give your module .ZIP file to import." colspan="4"/>
<field name="module_file"/>
</form>
'''
ask_fields = {
'module_file': {'string': 'Module .ZIP file', 'type': 'binary', 'required': True},
}
class move_module_wizard(wizard.interface):
def importzip(self, cr, uid, data, context):
module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
module_data = data['form']['module_file']
val =base64.decodestring(module_data)
fp = StringIO()
fp.write(val)
fdata = zipfile.ZipFile(fp, 'r')
fname = fdata.namelist()[0]
module_name = os.path.split(fname)[0]
ad = tools.config['addons_path']
fname = os.path.join(ad,module_name+'.zip')
try:
fp = file(fname, 'wb')
fp.write(val)
fp.close()
except IOError, e:
raise wizard.except_wizard(_('Error !'), _('Can not create the module file: %s !') % (fname,) )
pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid)
return {'module_name': module_name}
def _action_module_open(self, cr, uid, data, context):
return {
'domain': str([('name', '=', data['form']['module_name'])]),
'name': 'Module List',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'ir.module.module',
'view_id': False,
'type': 'ir.actions.act_window'
}
states = {
'init': {
'actions': [],
'result': {
'type': 'form',
'arch': ask_form,
'fields': ask_fields,
'state': [
('end', 'Close', 'gtk-cancel'),
('import', 'Import module', 'gtk-ok', True)
]
}
},
'import': {
'actions': [importzip],
'result': {
'type':'form',
'arch':finish_form,
'fields':{},
'state':[('open_window','Close')]
}
},
'open_window': {
'actions': [],
'result': {'type': 'action', 'action': _action_module_open, 'state':'end'}
},
}
move_module_wizard('base.module.import')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,83 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import tools
import pooler
view_form_end = """<?xml version="1.0"?>
<form string="Language file loaded.">
<image name="gtk-dialog-info" colspan="2"/>
<group colspan="2" col="4">
<separator string="Installation Done" colspan="4"/>
<label align="0.0" string="The selected language has been successfully installed.\nYou must change the preferences of the user and open a new menu to view changes." colspan="4"/>
</group>
</form>"""
view_form = """<?xml version="1.0"?>
<form string="System Upgrade">
<group colspan="2" col="4">
<separator string="System Upgrade" colspan="4"/>
<field name="lang" colspan="4" required="1"/>
<label align="0.0" string="Note that this operation may take a few minutes." colspan="4"/>
</group>
</form>"""
class wizard_lang_install(wizard.interface):
def _lang_install(self, cr, uid, data, context):
lang = data['form']['lang']
if lang:
modobj = pooler.get_pool(cr.dbname).get('ir.module.module')
mids = modobj.search(cr, uid, [('state', '=', 'installed')])
modobj.update_translations(cr, uid, mids, lang)
return {}
fields_form = {
'lang': {'string':'Language', 'type':'selection', 'selection':tools.scan_languages(),
'help': 'Choose a language to install.',
},
}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': view_form, 'fields': fields_form,
'state': [
('end', 'Close', 'gtk-cancel'),
('start', 'Start installation', 'gtk-ok', True)
]
}
},
'start': {
'actions': [_lang_install],
'result': {'type': 'form', 'arch': view_form_end, 'fields': {},
'state': [
('end', 'Ok', 'gtk-ok', True)
]
}
},
}
wizard_lang_install('module.lang.install')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,96 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
import pooler
class wizard_update_module(wizard.interface):
arch = '''<?xml version="1.0"?>
<form string="Scan for new modules">
<label string="This function will check for new modules in the 'addons' path" colspan="4" align="0.0"/>
</form>'''
fields = {
}
arch_module = '''<?xml version="1.0"?>
<form string="New modules">
<field name="update" colspan="4"/>
<field name="add" colspan="4"/>
</form>'''
fields_module = {
'update': {'type': 'integer', 'string': 'Number of modules updated', 'readonly': True},
'add': {'type': 'integer', 'string': 'Number of modules added', 'readonly': True},
}
def _update_module(self, cr, uid, data, context):
update, add = pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid)
return {'update': update, 'add': add}
def _action_module_open(self, cr, uid, data, context):
res = {
'domain': str([]),
'name': 'Module List',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'ir.module.module',
'view_id': False,
'type': 'ir.actions.act_window'
}
search_view_id = pooler.get_pool(cr.dbname).get('ir.ui.view').search(cr, uid, [('name','=','ir.module.module.list.select')], context=context)
if search_view_id:
res.update({'search_view_id' : search_view_id[0]})
return res
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': arch, 'fields': fields,
'state': [
('end', 'Close', 'gtk-cancel'),
('update', 'Check new modules', 'gtk-ok', True)
]
}
},
'update': {
'actions': [_update_module],
'result': {'type': 'form', 'arch': arch_module, 'fields': fields_module,
'state': [
('open_window', 'Ok', 'gtk-ok', True)
]
}
},
'open_window': {
'actions': [],
'result': {'type': 'action', 'action': _action_module_open, 'state':'end'}
}
}
wizard_update_module('module.module.update')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<wizard id="res_partner_mass_mailing_wizard" model="res.partner" name="res.partner.spam_send" string="Mass Mailing"/>
</data>
</openerp>
@@ -19,10 +19,10 @@
#
##############################################################################
import wizard_spam
import wizard_clear_ids
import wizard_ean_check
import partner_sms_send
import partner_wizard_spam
import partner_clear_ids
import partner_wizard_ean_check
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -15,26 +15,38 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import netsvc
from osv import fields, osv
class wizard_clear_ids(wizard.interface):
def _clear_ids(self, cr, uid, data, context):
service = netsvc.LocalService("object_proxy")
service.execute(cr.dbname, uid, 'res.partner', 'write', data['ids'], {'ref': False})
return {}
states = {
'init': {
'actions': [_clear_ids],
'result': {'type':'state', 'state':'end'}
}
}
wizard_clear_ids('res.partner.clear_ids')
class partner_clear_ids(osv.osv_memory):
""" Clear IDs """
_name = "partner.clear.ids"
_description = "Clear IDs"
def clear_ids(self, cr, uid, ids, context):
"""
Clear Ids
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
"""
partner_pool = self.pool.get('res.partner')
active_ids = context and context.get('active_ids', [])
res = {}
for partner in partner_pool.browse(cr, uid, active_ids, context=context):
if active_ids in partner:
res.update({'ref': False})
return res
partner_clear_ids()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_partner_clear_ids" model="ir.ui.view">
<field name="name">Clear IDs</field>
<field name="model">partner.clear.ids</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Clear Ids">
<label string="Want to Clear Ids ? "/>
<separator string="" colspan="6" />
<label string="" colspan="2"/>
<group>
<button special="cancel" string="Cancel" icon="gtk-cancel" />
<button name="clear_ids" string="Clear IDs" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_partner_clear_ids" model="ir.actions.act_window">
<field name="name">Clear IDs</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">partner.clear.ids</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import math
from osv import osv
from tools.misc import UpdateableStr
import pooler
class partner_wizard_ean_check(osv.osv_memory):
""" Ean check """
_name = "partner.wizard.ean.check"
_description = "Ean Check"
def is_pair(x):
return not x%2
def get_ean_key(string):
if not string or string=='':
return '0'
if len(string)!=12:
return '0'
sum = 0
for i in range(12):
if is_pair(i):
sum = sum + int(string[i])
else:
sum = sum + 3*int(string[i])
return str(int(math.ceil(sum/10.0)*10-sum))
def default_get(self, cr, fields, context):
partner_table = self.pool.get('res.partner')
ids = context.get('active_ids')
partners = partner_table.browse(cr, uid, ids)
_check_arch_lst = ['<?xml version="1.0"?>', '<form string="Check EAN13">', '<label string=""/>', '<label string=""/>','<label string="Original" />', '<label string="Computed" />']
for partner in partners:
if partner['ean13'] and len(partner['ean13'])>11 and len(partner['ean13'])<14:
_check_arch_lst.append('<label colspan="2" string="%s" />' % partner['ean13']);
key = get_ean_key(partner['ean13'][:12])
_check_arch_lst.append('<label string=""/>')
if len(partner['ean13'])==12:
_check_arch_lst.append('<label string="" />');
else:
_check_arch_lst.append('<label string="%s" />' % partner['ean13'][12])
_check_arch_lst.append('<label string="%s" />' % key)
_check_arch_lst.append('</form>')
_check_arch.string = '\n'.join(_check_arch_lst)
def update_ean(self, cr, uid, ids, context):
partner_table = self.pool.get('res.partner')
ids = context.get('active_ids')
partners = partner_table.browse(cr, uid, ids)
for partner in partners:
partner_table.write(cr, uid, ids, {
'ean13': "%s%s" % (partner['ean13'][:12], get_ean_key(partner['ean13'][:12]))
})
return {}
partner_wizard_ean_check()
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_partner_wizard_ean_check" model="ir.ui.view">
<field name="name">Ean check</field>
<field name="model">partner.wizard.ean.check</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Ean check">
<separator string="" colspan="4"/>
<label string="Want to check Ean ? "/>
<separator string="" colspan="6" />
<label string="" colspan="2"/>
<group>
<button special="cancel" string="Ignore" icon="gtk-cancel" />
<button name="update_ean" string="Correct EAN13" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="action_view_partner_wizard_ean_check" model="ir.actions.act_window">
<field name="name">Ean check</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">partner.wizard.ean.check</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</openerp>
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import netsvc
import tools
from osv import fields, osv
class partner_wizard_spam(osv.osv_memory):
""" Mass Mailing """
_name = "partner.wizard.spam"
_description = "Mass Mailing"
_columns = {
'email_from': fields.char("Sender's email", size=256, required=True),
'subject': fields.char('Subject', size=256,required=True),
'text': fields.text('Message',required=True),
}
def mass_mail_send(self, cr, uid, ids, context):
"""
Send Email
@param cr: the current row, from the database cursor.
@param uid: the current user’s ID for security checks.
@param ids: the ID or list of IDs
@param context: A standard dictionary
"""
nbr = 0
partner_pool = self.pool.get('res.partner')
data = self.browse(cr, uid, ids, context=context)
event_pool = self.pool.get('res.partner.event')
active_ids = context and context.get('active_ids', [])
partners = partner_pool.browse(cr, uid, active_ids, context)
for partner in partners:
for adr in partner.address:
if adr.email:
name = adr.name or partner.name
to = '%s <%s>' % (name, adr.email)
#TODO: add some tests to check for invalid email addresses
#CHECKME: maybe we should use res.partner/email_send
tools.email_send(data.email_from, [to], data.subject, data.text,subtype='html')
nbr += 1
event_pool.create(cr, uid,
{'name': 'Email sent through mass mailing',
'partner_id': partner.id,
'description': data.text })
#TODO: log number of message sent
return {'email_sent': nbr}
partner_wizard_spam()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_partner_mass_mail" model="ir.ui.view">
<field name="name">Mass Mailing</field>
<field name="model">partner.wizard.spam</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Mass Mailing" col="4">
<field name="email_from"/>
<newline/>
<field name="subject"/>
<newline/>
<field name="text" widget="text_tag"/>
<newline/>
<separator string="" colspan="6"/>
<group colspan="6" col="4" >
<button special="cancel" string="Cancel" icon="gtk-cancel" />
<button name="mass_mail_send" string="Send Email" type="object" icon="gtk-go-forward"/>
</group>
</form>
</field>
</record>
<act_window name="Mass Mailing"
res_model="partner.wizard.spam"
src_model="res.partner"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_partner_mass_mail"/>
</data>
</openerp>
@@ -1,98 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import math
from osv import osv
from tools.misc import UpdateableStr
import pooler
def _is_pair(x):
return not x%2
def _get_ean_key(string):
if not string or string=='':
return '0'
if len(string)!=12:
return '0'
sum=0
for i in range(12):
if _is_pair(i):
sum+=int(string[i])
else:
sum+=3*int(string[i])
return str(int(math.ceil(sum/10.0)*10-sum))
#FIXME: this is not concurrency safe !!!!
_check_arch = UpdateableStr()
_check_fields = {}
def _check_key(self, cr, uid, data, context):
partner_table=pooler.get_pool(cr.dbname).get('res.partner')
partners = partner_table.browse(cr, uid, data['ids'])
_check_arch_lst=['<?xml version="1.0"?>', '<form string="Check EAN13">', '<label string=""/>', '<label string=""/>','<label string="Original" />', '<label string="Computed" />']
for partner in partners:
if partner['ean13'] and len(partner['ean13'])>11 and len(partner['ean13'])<14:
_check_arch_lst.append('<label colspan="2" string="%s" />' % partner['ean13']);
key=_get_ean_key(partner['ean13'][:12])
_check_arch_lst.append('<label string=""/>')
if len(partner['ean13'])==12:
_check_arch_lst.append('<label string="" />');
else:
_check_arch_lst.append('<label string="%s" />' % partner['ean13'][12])
_check_arch_lst.append('<label string="%s" />' % key)
_check_arch_lst.append('</form>')
_check_arch.string = '\n'.join(_check_arch_lst)
return {}
def _update_ean(self, cr, uid, data, context):
partner_table = pooler.get_pool(cr.dbname).get('res.partner')
partners = partner_table.browse(cr, uid, data['ids'])
for partner in partners:
partner_table.write(cr, uid, data['ids'], {
'ean13': "%s%s" % (partner['ean13'][:12], _get_ean_key(partner['ean13'][:12]))
})
return {}
class wiz_ean_check(wizard.interface):
states = {
'init': {
'actions': [_check_key],
'result': {
'type': 'form',
'arch': _check_arch,
'fields': _check_fields,
'state': (('end', 'Ignore'), ('correct', 'Correct EAN13'))
}
},
'correct' : {
'actions': [_update_ean],
'result': {
'type': 'state',
'state': 'end'
}
}
}
wiz_ean_check('res.partner.ean13')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -1,75 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
import tools
email_send_form = '''<?xml version="1.0"?>
<form string="Mass Mailing">
<field name="from"/>
<newline/>
<field name="subject"/>
<newline/>
<field name="text"/>
</form>'''
email_send_fields = {
'from': {'string':"Sender's email", 'type':'char', 'size':64, 'required':True},
'subject': {'string':'Subject', 'type':'char', 'size':64, 'required':True},
'text': {'string':'Message', 'type':'text_tag', 'required':True}
}
# this sends an email to ALL the addresses of the selected partners.
def _mass_mail_send(self, cr, uid, data, context):
nbr = 0
partners = pooler.get_pool(cr.dbname).get('res.partner').browse(cr, uid, data['ids'], context)
for partner in partners:
for adr in partner.address:
if adr.email:
name = adr.name or partner.name
to = '%s <%s>' % (name, adr.email)
#TODO: add some tests to check for invalid email addresses
#CHECKME: maybe we should use res.partner/email_send
tools.email_send(data['form']['from'], [to], data['form']['subject'], data['form']['text'],subtype='html')
nbr += 1
pooler.get_pool(cr.dbname).get('res.partner.event').create(cr, uid,
{'name': 'Email sent through mass mailing',
'partner_id': partner.id,
'description': data['form']['text'], })
#TODO: log number of message sent
return {'email_sent': nbr}
class part_email(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': email_send_form, 'fields': email_send_fields, 'state':[('end','Cancel'), ('send','Send Email')]}
},
'send': {
'actions': [_mass_mail_send],
'result': {'type': 'state', 'state':'end'}
}
}
part_email('res.partner.spam_send')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: