From 0330c457715525b3cb1bc18406daec56fa5de4fe Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Tue, 19 Jul 2016 12:51:10 -0700 Subject: [PATCH] [MIG] base_export_manager: Upgrade to v9 * Upgrade base_export_manager to v9 * Rename JS to base_export_manager --- base_export_manager/README.rst | 3 +- base_export_manager/__init__.py | 2 +- base_export_manager/__openerp__.py | 6 +- base_export_manager/models/__init__.py | 2 +- base_export_manager/models/ir_exports_line.py | 21 ++--- .../static/description/icon.svg | 79 ------------------- .../static/src/js/base_export_manager.js | 27 +++++++ base_export_manager/static/src/js/main.js | 32 -------- base_export_manager/tests/__init__.py | 4 +- .../tests/test_ir_exports_line.py | 2 +- base_export_manager/views/assets.xml | 8 +- base_export_manager/views/ir_exports_view.xml | 7 +- 12 files changed, 55 insertions(+), 138 deletions(-) delete mode 100644 base_export_manager/static/description/icon.svg create mode 100644 base_export_manager/static/src/js/base_export_manager.js delete mode 100644 base_export_manager/static/src/js/main.js diff --git a/base_export_manager/README.rst b/base_export_manager/README.rst index a202b9954..79a28887d 100644 --- a/base_export_manager/README.rst +++ b/base_export_manager/README.rst @@ -43,7 +43,7 @@ To use one of those profiles, you need to: .. 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 + :target: https://runbot.odoo-community.org/runbot/149/9.0 Known issues / Roadmap ====================== @@ -69,6 +69,7 @@ Contributors * Javier Iniesta * Rafael Blasco * Jairo Llopis +* Dave Lasley Maintainer ---------- diff --git a/base_export_manager/__init__.py b/base_export_manager/__init__.py index 9861d230b..13d8b17b5 100644 --- a/base_export_manager/__init__.py +++ b/base_export_manager/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingeniería S.L. - Antonio Espinosa +# Copyright 2015 Antiun Ingeniería S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/base_export_manager/__openerp__.py b/base_export_manager/__openerp__.py index 1ac8b1d71..477f749c5 100644 --- a/base_export_manager/__openerp__.py +++ b/base_export_manager/__openerp__.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingeniería S.L. - Antonio Espinosa +# Copyright 2015 Antiun Ingeniería S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': "Manage model export profiles", 'category': 'Personalization', - 'version': '8.0.2.0.0', + 'version': '9.0.1.0.0', 'depends': [ 'web', ], @@ -19,8 +19,10 @@ ], 'author': 'Antiun Ingeniería S.L., ' 'Tecnativa, ' + 'LasLabs, ' 'Odoo Community Association (OCA)', 'website': 'http://www.antiun.com', 'license': 'AGPL-3', 'installable': True, + 'application': False, } diff --git a/base_export_manager/models/__init__.py b/base_export_manager/models/__init__.py index b8bdda5bf..792a2e8bd 100644 --- a/base_export_manager/models/__init__.py +++ b/base_export_manager/models/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingeniería S.L. - Antonio Espinosa +# Copyright 2015 Antiun Ingeniería S.L. - Antonio Espinosa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import ir_exports, ir_exports_line diff --git a/base_export_manager/models/ir_exports_line.py b/base_export_manager/models/ir_exports_line.py index 46993439b..d4c268099 100644 --- a/base_export_manager/models/ir_exports_line.py +++ b/base_export_manager/models/ir_exports_line.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingeniería S.L. - Antonio Espinosa +# Copyright 2015 Antiun Ingeniería S.L. - Antonio Espinosa # Copyright 2015-2016 Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -127,17 +127,18 @@ class IrExportsLine(models.Model): s[s.field_n(num, True)] = self._get_field_id( model, field_name) - @api.one + @api.multi @api.constrains("field1_id", "field2_id", "field3_id") def _check_name(self): - if not self.label: - 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) + for rec_id in self: + if not rec_id.label: + raise exceptions.ValidationError( + _("Field '%s' does not exist") % rec_id.name) + lines = self.search([('export_id', '=', rec_id.export_id.id), + ('name', '=', rec_id.name)]) + if len(lines) > 1: + raise exceptions.ValidationError( + _("Field '%s' already exists") % rec_id.name) @api.model def _install_base_export_manager(self): diff --git a/base_export_manager/static/description/icon.svg b/base_export_manager/static/description/icon.svg deleted file mode 100644 index a7a26d093..000000000 --- a/base_export_manager/static/description/icon.svg +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/base_export_manager/static/src/js/base_export_manager.js b/base_export_manager/static/src/js/base_export_manager.js new file mode 100644 index 000000000..cf8c52d20 --- /dev/null +++ b/base_export_manager/static/src/js/base_export_manager.js @@ -0,0 +1,27 @@ +/* Copyright 2015 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + */ + +odoo.define('base_export_manager.base_export_manager', function(require) { + 'use strict'; + + var DataExport = require('web.DataExport'); + + 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)); + } + }, + }); + +}); diff --git a/base_export_manager/static/src/js/main.js b/base_export_manager/static/src/js/main.js deleted file mode 100644 index 43d04a5fe..000000000 --- a/base_export_manager/static/src/js/main.js +++ /dev/null @@ -1,32 +0,0 @@ -/* © 2015 Antiun Ingeniería S.L. - Antonio Espinosa - * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */ - -// 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/tests/__init__.py b/base_export_manager/tests/__init__.py index 07077ba6d..242cd85cd 100644 --- a/base_export_manager/tests/__init__.py +++ b/base_export_manager/tests/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingeniería S.L. - Javier Iniesta -# © 2015 Antiun Ingeniería S.L. - Jairo Llopis +# Copyright 2015 Antiun Ingeniería S.L. - Javier Iniesta +# Copyright 2015 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import test_ir_exports, 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 index 4954cc5e0..acfb3cc3a 100644 --- a/base_export_manager/tests/test_ir_exports_line.py +++ b/base_export_manager/tests/test_ir_exports_line.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2015 Antiun Ingenieria S.L. - Javier Iniesta +# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp.tests.common import TransactionCase diff --git a/base_export_manager/views/assets.xml b/base_export_manager/views/assets.xml index 1c8d99a66..49157a606 100644 --- a/base_export_manager/views/assets.xml +++ b/base_export_manager/views/assets.xml @@ -1,6 +1,5 @@ - - +