diff --git a/base_export_manager/README.rst b/base_export_manager/README.rst new file mode 100644 index 000000000..60f6b53a0 --- /dev/null +++ b/base_export_manager/README.rst @@ -0,0 +1,60 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================= +Manages model export profiles +============================= + +This module allow admin to manage export profiles (ir.exports) that Odoo +doesn't show anywhere. + +Usage +===== + +To manage export profiles at Settings > Technical > User Interface > Export profiles + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/149/8.0 + +Known issues / Roadmap +====================== + +* Module must enable the functionality for creating export profiles from that view so: + + * Field resource must show all models available to export + * Field "Field name" must show fields from that model + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Antonio Espinosa +* Javier Iniesta + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file diff --git a/base_export_manager/__init__.py b/base_export_manager/__init__.py new file mode 100644 index 000000000..d72ccb3f5 --- /dev/null +++ b/base_export_manager/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright : +# (c) 2015 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) +# Antonio Espinosa +# +# 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 models diff --git a/base_export_manager/__openerp__.py b/base_export_manager/__openerp__.py new file mode 100644 index 000000000..0d2c49aa2 --- /dev/null +++ b/base_export_manager/__openerp__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ +############################################################################## +# +# OpenERP, Odoo Source Management Solution +# Copyright (c) 2015 Antiun Ingeniería S.L. (http://www.antiun.com) +# Antonio Espinosa +# +# 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': "Manages model export profiles", + 'category': 'Personalization', + 'version': '8.0.1.0.0', + 'depends': [ + 'web', + ], + 'data': [ + 'views/assets.xml', + 'views/ir_exports_view.xml', + ], + 'qweb': [ + "static/src/xml/base.xml", + ], + 'author': 'Antiun Ingeniería S.L.,Odoo Community Association (OCA)', + 'website': 'http://www.antiun.com', + 'license': 'AGPL-3', + 'installable': True, +} diff --git a/base_export_manager/i18n/base_exports_manager.pot b/base_export_manager/i18n/base_exports_manager.pot new file mode 100644 index 000000000..973fa809c --- /dev/null +++ b/base_export_manager/i18n/base_exports_manager.pot @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_exports_manager +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-27 12:38+0000\n" +"PO-Revision-Date: 2015-10-27 12:38+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: base_exports_manager +#: view:ir.exports:base_exports_manager.ir_exports_form_view +msgid "Export Profile" +msgstr "" + +#. module: base_exports_manager +#: model:ir.actions.act_window,name:base_exports_manager.ir_exports_action +#: view:ir.exports:base_exports_manager.ir_exports_tree_view +#: model:ir.ui.menu,name:base_exports_manager.ir_exports_menu +msgid "Export Profiles" +msgstr "" + +#. module: base_exports_manager +#: code:addons/base_exports_manager/models/ir_exports_line.py:62 +#, python-format +msgid "Field '%s' already exists" +msgstr "" + +#. module: base_exports_manager +#: code:addons/base_exports_manager/models/ir_exports_line.py:57 +#, python-format +msgid "Field '%s' does not exist" +msgstr "" + +#. module: base_exports_manager +#: field:ir.exports.line,sequence:0 +msgid "Sequence" +msgstr "" + +#. module: base_exports_manager +#: field:ir.exports.line,label:0 +msgid "Label" +msgstr "" diff --git a/base_export_manager/i18n/es.po b/base_export_manager/i18n/es.po new file mode 100644 index 000000000..9a4c03cba --- /dev/null +++ b/base_export_manager/i18n/es.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_exports_manager +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-27 12:38+0000\n" +"PO-Revision-Date: 2015-10-27 12:38+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: base_exports_manager +#: view:ir.exports:base_exports_manager.ir_exports_form_view +msgid "Export Profile" +msgstr "Perfil de exportación" + +#. module: base_exports_manager +#: model:ir.actions.act_window,name:base_exports_manager.ir_exports_action +#: view:ir.exports:base_exports_manager.ir_exports_tree_view +#: model:ir.ui.menu,name:base_exports_manager.ir_exports_menu +msgid "Export Profiles" +msgstr "Perfiles de exportación" + +#. module: base_exports_manager +#: code:addons/base_exports_manager/models/ir_exports_line.py:62 +#, python-format +msgid "Field '%s' already exists" +msgstr "El campo '%s' ya existe" + +#. module: base_exports_manager +#: code:addons/base_exports_manager/models/ir_exports_line.py:57 +#, python-format +msgid "Field '%s' does not exist" +msgstr "El campo '%s' no existe" + +#. module: base_exports_manager +#: field:ir.exports.line,sequence:0 +msgid "Sequence" +msgstr "Secuencia" + +#. module: base_exports_manager +#: field:ir.exports.line,label:0 +msgid "Label" +msgstr "Etiqueta" diff --git a/base_export_manager/models/__init__.py b/base_export_manager/models/__init__.py new file mode 100644 index 000000000..e9d191673 --- /dev/null +++ b/base_export_manager/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright : +# (c) 2015 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) +# Antonio Espinosa +# +# 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_exports_line diff --git a/base_export_manager/models/ir_exports_line.py b/base_export_manager/models/ir_exports_line.py new file mode 100644 index 000000000..23932bba5 --- /dev/null +++ b/base_export_manager/models/ir_exports_line.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright : +# (c) 2015 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) +# Antonio Espinosa +# +# 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 import models, fields, api, exceptions +from openerp.tools.translate import _ + + +class IrExportsLine(models.Model): + _inherit = 'ir.exports.line' + _order = 'sequence,id' + + sequence = fields.Integer() + label = fields.Char(string='Label', compute="_get_label") + + def _get_label_string(self): + self.ensure_one() + model_name = self.export_id.resource + label = '' + if not self.name: + return False + for field in self.name.split('/'): + model = self.env['ir.model'].search([('model', '=', model_name)]) + field_obj = model.field_id.filtered(lambda r: r.name == field) + if not field_obj: + return False + label = label + _(field_obj.field_description) + '/' + model_name = field_obj.relation + return label.rstrip('/') + ' (' + self.name + ')' + + @api.one + @api.constrains('name') + def _check_name(self): + if not self._get_label_string(): + raise exceptions.ValidationError( + _("Field '%s' does not exist") % self.name) + lines = self.search([('export_id', '=', self.export_id.id), + ('name', '=', self.name)]) + if len(lines) > 1: + raise exceptions.ValidationError( + _("Field '%s' already exists") % self.name) + + @api.one + @api.depends('name') + def _get_label(self): + self.label = self._get_label_string() + + @api.onchange('name') + def _onchange_name(self): + self.label = self._get_label_string() diff --git a/base_export_manager/static/description/icon.png b/base_export_manager/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/base_export_manager/static/description/icon.png differ diff --git a/base_export_manager/static/description/icon.svg b/base_export_manager/static/description/icon.svg new file mode 100644 index 000000000..a7a26d093 --- /dev/null +++ b/base_export_manager/static/description/icon.svg @@ -0,0 +1,79 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/base_export_manager/static/src/js/main.js b/base_export_manager/static/src/js/main.js new file mode 100644 index 000000000..480768164 --- /dev/null +++ b/base_export_manager/static/src/js/main.js @@ -0,0 +1,54 @@ +/** + * # -*- coding: utf-8 -*- + * ############################################################################## + * # + * # OpenERP, Open Source Management Solution + * # This module copyright : + * # (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) + * # Antonio Espinosa + * # + * # 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 . + * # + * ############################################################################## + */ + +// Check jQuery available +if (typeof jQuery === 'undefined') { throw new Error('Requires jQuery') } + ++function ($) { + 'use strict'; + + openerp.base_exports_manager = function(instance, local) { + var _t = instance.web._t, + _lt = instance.web._lt; + var QWeb = instance.web.qweb; + + instance.web.DataExport.include({ + do_load_export_field: function(field_list) { + var export_node = this.$el.find("#fields_list"); + _(field_list).each(function (field) { + export_node.append(new Option(field.label + ' (' + field.name + ')', field.name)); + }); + }, + add_field: function(field_id, string) { + var field_list = this.$el.find('#fields_list'); + if (this.$el.find("#fields_list option[value='" + field_id + "']") + && !this.$el.find("#fields_list option[value='" + field_id + "']").length) { + field_list.append(new Option(string + ' (' + field_id + ')', field_id)); + } + }, + }); + } + +}(jQuery); diff --git a/base_export_manager/static/src/xml/base.xml b/base_export_manager/static/src/xml/base.xml new file mode 100644 index 000000000..744d005ac --- /dev/null +++ b/base_export_manager/static/src/xml/base.xml @@ -0,0 +1,10 @@ + + + + + + () + + + + diff --git a/base_export_manager/tests/__init__.py b/base_export_manager/tests/__init__.py new file mode 100644 index 000000000..780771a3a --- /dev/null +++ b/base_export_manager/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# License AGPL-3: Antiun Ingenieria S.L. - Javier Iniesta +# See README.rst file on addon root folder for more details + +from . import test_ir_exports_line diff --git a/base_export_manager/tests/test_ir_exports_line.py b/base_export_manager/tests/test_ir_exports_line.py new file mode 100644 index 000000000..65b64f489 --- /dev/null +++ b/base_export_manager/tests/test_ir_exports_line.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# License AGPL-3: Antiun Ingenieria S.L. - Javier Iniesta +# See README.rst file on addon root folder for more details + +from openerp.tests.common import TransactionCase +from openerp.exceptions import ValidationError + + +class TestIrExportsLineCase(TransactionCase): + + def setUp(self): + super(TestIrExportsLineCase, self).setUp() + m_ir_exports = self.env['ir.exports'] + self.export = m_ir_exports.create({'name': 'Partner Test', + 'resource': 'res.partner'}) + + def test_check_name(self): + m_ir_exports_line = self.env['ir.exports.line'] + m_ir_exports_line.create({'name': 'name', + 'export_id': self.export.id}) + with self.assertRaises(ValidationError): + m_ir_exports_line.create({'name': 'name', + 'export_id': self.export.id}) + with self.assertRaises(ValidationError): + m_ir_exports_line.create({'name': 'bad_error_name', + 'export_id': self.export.id}) + + def test_get_label_string(self): + m_ir_exports_line = self.env['ir.exports.line'] + export_line = m_ir_exports_line.create({'name': 'parent_id/name', + 'export_id': self.export.id}) + self.assertEqual(export_line.label, + "Related Company/Name (parent_id/name)") + with self.assertRaises(ValidationError): + m_ir_exports_line.create({'name': '', + 'export_id': self.export.id}) diff --git a/base_export_manager/views/assets.xml b/base_export_manager/views/assets.xml new file mode 100644 index 000000000..16c00e502 --- /dev/null +++ b/base_export_manager/views/assets.xml @@ -0,0 +1,17 @@ + + + + + +