diff --git a/defer_parent_store_computation_import/__init__.py b/defer_parent_store_computation_import/__init__.py new file mode 100644 index 000000000..a8eefccd3 --- /dev/null +++ b/defer_parent_store_computation_import/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2010 - 2014 Savoir-faire Linux +# (). +# +# 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 . +# +############################################################################## + +from . import ir_import diff --git a/defer_parent_store_computation_import/__openerp__.py b/defer_parent_store_computation_import/__openerp__.py new file mode 100644 index 000000000..d7d972bee --- /dev/null +++ b/defer_parent_store_computation_import/__openerp__.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2010 - 2014 Savoir-faire Linux +# (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'Deferred Parent Computation Import', + 'description': """ +Deferred Parent Computation Import +================================== + +Add option to import with deferred parent computation. + +When importing large amounts of data, the parent store +computation can have major negative performance issues. + +Deferring the parent store computation to the end of the import +can speed long imports tremendously. + +Contributors +------------ +* Sandy Carter +* Pedro M. Baeza + +""", + 'category': 'Uncategorized', + 'author': "Savoir-faire Linux", + 'website': "http://www.savoirfairelinux.com", + 'depends': ['base_import'], + 'installable': True, + 'auto_install': False, + 'data': [ + ], + 'qweb': ['static/src/xml/defer_parent_store_computation_import.xml'], + 'js': ['static/src/js/defer_parent_store_computation_import.js'], +} diff --git a/defer_parent_store_computation_import/i18n/defer_parent_store_computation_import.pot b/defer_parent_store_computation_import/i18n/defer_parent_store_computation_import.pot new file mode 100644 index 000000000..7ac162e52 --- /dev/null +++ b/defer_parent_store_computation_import/i18n/defer_parent_store_computation_import.pot @@ -0,0 +1,33 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * defer_parent_store_computation_import +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-12-19 01:13+0000\n" +"PO-Revision-Date: 2014-12-19 01:13+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: defer_parent_store_computation_import +#: model:ir.model,name:defer_parent_store_computation_import.model_base_import_import +msgid "base_import.import" +msgstr "" + +#. module: defer_parent_store_computation_import +#: field:base_import.import,defer_parent_store_computation:0 +msgid "Defer Parent Store Computation" +msgstr "" + +#. module: defer_parent_store_computation_import +#. openerp-web +#: code:addons/defer_parent_store_computation_import/static/src/xml/defer_parent_store_computation_import.xml:9 +#, python-format +msgid "Use deferred parent store computation method" +msgstr "" diff --git a/defer_parent_store_computation_import/i18n/fr.po b/defer_parent_store_computation_import/i18n/fr.po new file mode 100644 index 000000000..0506b5e8e --- /dev/null +++ b/defer_parent_store_computation_import/i18n/fr.po @@ -0,0 +1,35 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * defer_parent_store_computation_import +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-12-19 01:13+0000\n" +"PO-Revision-Date: 2014-12-18 20:16-0500\n" +"Last-Translator: Sandy Carter \n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 1.7.1\n" + +#. module: defer_parent_store_computation_import +#: model:ir.model,name:defer_parent_store_computation_import.model_base_import_import +msgid "base_import.import" +msgstr "" + +#. module: defer_parent_store_computation_import +#: field:base_import.import,defer_parent_store_computation:0 +msgid "Defer Parent Store Computation" +msgstr "Reporter la computation de la parenté" + +#. module: defer_parent_store_computation_import +#. openerp-web +#: code:addons/defer_parent_store_computation_import/static/src/xml/defer_parent_store_computation_import.xml:9 +#, python-format +msgid "Use deferred parent store computation method" +msgstr "Utiliser la méthode de reportage de la computation de la parenté" diff --git a/defer_parent_store_computation_import/ir_import.py b/defer_parent_store_computation_import/ir_import.py new file mode 100644 index 000000000..02ec6d146 --- /dev/null +++ b/defer_parent_store_computation_import/ir_import.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2010 - 2014 Savoir-faire Linux +# (). +# +# 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 . +# +############################################################################## + +from openerp.osv import orm + + +class ir_import(orm.TransientModel): + _inherit = 'base_import.import' + + def do(self, cr, uid, id, fields, options, dryrun=False, context=None): + """When importing large amounts of data, the parent store + computation can have major negative performance issues. + + Deferring the parent store computation to the end of the import + can speed long imports tremendously. + """ + + defer = options.get('defer') + + if defer: + context['defer_parent_store_computation'] = True + + res = super(ir_import, self).do( + cr, uid, id, fields, options, dryrun, context=context + ) + + if not dryrun and defer: + record = self.browse(cr, uid, id, context=context) + self.pool[record.res_model]._parent_store_compute(cr) + + return res diff --git a/defer_parent_store_computation_import/static/src/js/defer_parent_store_computation_import.js b/defer_parent_store_computation_import/static/src/js/defer_parent_store_computation_import.js new file mode 100644 index 000000000..27dcddb3f --- /dev/null +++ b/defer_parent_store_computation_import/static/src/js/defer_parent_store_computation_import.js @@ -0,0 +1,15 @@ +openerp.defer_parent_store_computation_import = function (instance) { + var QWeb = instance.web.qweb; + var _t = instance.web._t; + var _lt = instance.web._lt; + + instance.web.DataImport.include({ + import_options: function () { + var options = this._super.apply(this, arguments); + options['defer'] = this.$('input.oe_import_use_deferred_store_computation').prop('checked') + return options; + }, + }); + +}; + diff --git a/defer_parent_store_computation_import/static/src/xml/defer_parent_store_computation_import.xml b/defer_parent_store_computation_import/static/src/xml/defer_parent_store_computation_import.xml new file mode 100644 index 000000000..62cecee45 --- /dev/null +++ b/defer_parent_store_computation_import/static/src/xml/defer_parent_store_computation_import.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + +