From 8cb7921a9b6b394eb796a778bae322b84ca39550 Mon Sep 17 00:00:00 2001 From: serpentcs Date: Tue, 24 Jan 2017 18:49:06 +0530 Subject: [PATCH] [MIG]Migrated base_export_manager module. --- base_export_manager/__manifest__.py | 2 +- base_export_manager/models/ir_exports.py | 4 +- base_export_manager/models/ir_exports_line.py | 4 +- base_export_manager/models/ir_model_access.py | 2 +- base_export_manager/models/res_users.py | 2 +- .../static/src/js/base_export_manager.js | 83 ++++--------------- base_export_manager/static/src/xml/base.xml | 4 +- base_export_manager/tests/test_ir_exports.py | 4 +- .../tests/test_ir_exports_line.py | 7 +- 9 files changed, 33 insertions(+), 79 deletions(-) diff --git a/base_export_manager/__manifest__.py b/base_export_manager/__manifest__.py index b5a9be9..a99f74e 100644 --- a/base_export_manager/__manifest__.py +++ b/base_export_manager/__manifest__.py @@ -5,7 +5,7 @@ { 'name': "Manage model export profiles", 'category': 'Personalization', - 'version': '9.0.1.1.0', + 'version': '10.0.1.0.0', 'depends': [ 'web', ], diff --git a/base_export_manager/models/ir_exports.py b/base_export_manager/models/ir_exports.py index 5236960..1e48b93 100644 --- a/base_export_manager/models/ir_exports.py +++ b/base_export_manager/models/ir_exports.py @@ -2,8 +2,8 @@ # Copyright 2015-2016 Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import _, api, fields, models -from openerp.exceptions import ValidationError +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError class IrExports(models.Model): diff --git a/base_export_manager/models/ir_exports_line.py b/base_export_manager/models/ir_exports_line.py index 581c39f..9d901c2 100644 --- a/base_export_manager/models/ir_exports_line.py +++ b/base_export_manager/models/ir_exports_line.py @@ -3,8 +3,8 @@ # Copyright 2015-2016 Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, fields, api, exceptions -from openerp.tools.translate import _ +from odoo import models, fields, api, exceptions +from odoo.tools.translate import _ class IrExportsLine(models.Model): diff --git a/base_export_manager/models/ir_model_access.py b/base_export_manager/models/ir_model_access.py index 24fed72..7dfc163 100644 --- a/base_export_manager/models/ir_model_access.py +++ b/base_export_manager/models/ir_model_access.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -from openerp import models, fields +from odoo import models, fields class IrModelAccess(models.Model): diff --git a/base_export_manager/models/res_users.py b/base_export_manager/models/res_users.py index 759bf26..4db9dd6 100644 --- a/base_export_manager/models/res_users.py +++ b/base_export_manager/models/res_users.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -from openerp import api, models +from odoo import api, models class ResUsers(models.Model): diff --git a/base_export_manager/static/src/js/base_export_manager.js b/base_export_manager/static/src/js/base_export_manager.js index a5a642e..e24d15e 100644 --- a/base_export_manager/static/src/js/base_export_manager.js +++ b/base_export_manager/static/src/js/base_export_manager.js @@ -5,58 +5,13 @@ odoo.define('base_export_manager.base_export_manager', function(require) { 'use strict'; - var jQuery = require('$'); - var DataExport = require('web.DataExport'); var core = require('web.core'); var Model = require('web.DataModel'); var ListView = require('web.ListView'); var Sidebar = require('web.Sidebar'); var _t = core._t; - var Session = require('web.Session'); - var session = require('web.session'); - - - 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)); - } - }, - }); - - - Session.include({ - get_export_models: function() { - if (!this.uid) { - return $.when().resolve(false); - } - var Users = new Model('res.users'); - var export_models = Users.call('fetch_export_models', []); - return export_models; - }, - }); ListView.include({ - view_loading: function(fvg) { - this._super(fvg); - this.is_export_manager(); - }, - is_export_manager: function () { - var self = this; - $.when(self.session.get_export_models()).then(function - (export_models) { - self.export_models=export_models; - }); - }, /** * Instantiate and render the sidebar. * Sets this.sidebar @@ -66,26 +21,24 @@ odoo.define('base_export_manager.base_export_manager', function(require) { **/ render_sidebar: function($node) { var self = this; - self.render_export_enable = jQuery.inArray( this.model, self.export_models ); - if (!this.sidebar && this.options.sidebar) { - this.sidebar = new Sidebar(this, {editable: this.is_action_enabled('edit')}); - if (this.fields_view.toolbar) { - this.sidebar.add_toolbar(this.fields_view.toolbar); - } - this.sidebar.add_items('other', _.compact([ - self.render_export_enable >= 0 && {label: _t("Export"), callback: this.on_sidebar_export}, - this.fields_view.fields.active && {label: _t("Archive"), callback: this.do_archive_selected}, - this.fields_view.fields.active && {label: _t("Unarchive"), callback: this.do_unarchive_selected}, - this.is_action_enabled('delete') && {label: _t('Delete'), callback: this.do_delete_selected} - ])); - - $node = $node || this.options.$sidebar; - this.sidebar.appendTo($node); - - // Hide the sidebar by default (it will be shown as soon as a record is selected) - this.sidebar.do_hide(); - } + this._super($node); + var Users = new Model('res.users'); + Users.call('fetch_export_models', []).done(function(export_models){ + self.export_models = export_models; + self.render_export_enable = jQuery.inArray( self.model, self.export_models ); + if(self.sidebar && self.sidebar.items && self.sidebar.items.other){ + var items_data = []; + _.each(self.sidebar.items.other,function(rec){ + if(rec.label != _t("Export")){ + items_data.push(rec); + } + }); + self.sidebar.items.other = items_data; + self.sidebar.add_items('other', _.compact([ + self.render_export_enable >= 0 && {label: _t("Export"), callback: self.on_sidebar_export}, + ])); + } + }); }, }); - }); diff --git a/base_export_manager/static/src/xml/base.xml b/base_export_manager/static/src/xml/base.xml index b9b51f2..b26077a 100644 --- a/base_export_manager/static/src/xml/base.xml +++ b/base_export_manager/static/src/xml/base.xml @@ -1,8 +1,8 @@ - - + + () diff --git a/base_export_manager/tests/test_ir_exports.py b/base_export_manager/tests/test_ir_exports.py index 983c995..f5c9041 100644 --- a/base_export_manager/tests/test_ir_exports.py +++ b/base_export_manager/tests/test_ir_exports.py @@ -2,8 +2,8 @@ # © 2015 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.exceptions import ValidationError -from openerp.tests.common import TransactionCase +from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase class TestIrExportsCase(TransactionCase): diff --git a/base_export_manager/tests/test_ir_exports_line.py b/base_export_manager/tests/test_ir_exports_line.py index bcfa3cb..b9639e0 100644 --- a/base_export_manager/tests/test_ir_exports_line.py +++ b/base_export_manager/tests/test_ir_exports_line.py @@ -3,8 +3,8 @@ # Copyright 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.tests.common import TransactionCase -from openerp.exceptions import ValidationError +from odoo.tests.common import TransactionCase +from odoo.exceptions import ValidationError class TestIrExportsLineCase(TransactionCase): @@ -37,8 +37,9 @@ class TestIrExportsLineCase(TransactionCase): 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}) + check_label = " (res.partner) (parent_id/name)" self.assertEqual(export_line.with_context(lang="en_US").label, - "Related Company/Name (parent_id/name)") + "Related Company (res.partner)/Name" + check_label) with self.assertRaises(ValidationError): m_ir_exports_line.create({'name': '', 'export_id': self.export.id})