Browse Source

[MIG]Migrated base_export_manager module.

pull/67/head
serpentcs 8 years ago
committed by Olivier Jossen
parent
commit
53ace2cb81
  1. 2
      base_export_manager/__manifest__.py
  2. 4
      base_export_manager/models/ir_exports.py
  3. 4
      base_export_manager/models/ir_exports_line.py
  4. 2
      base_export_manager/models/ir_model_access.py
  5. 2
      base_export_manager/models/res_users.py
  6. 77
      base_export_manager/static/src/js/base_export_manager.js
  7. 4
      base_export_manager/static/src/xml/base.xml
  8. 4
      base_export_manager/tests/test_ir_exports.py
  9. 7
      base_export_manager/tests/test_ir_exports_line.py

2
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',
],

4
base_export_manager/models/ir_exports.py

@ -2,8 +2,8 @@
# Copyright 2015-2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# 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):

4
base_export_manager/models/ir_exports_line.py

@ -3,8 +3,8 @@
# Copyright 2015-2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# 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):

2
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):

2
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):

77
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._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);
}
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}
});
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},
]));
$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();
}
});
},
});
});

4
base_export_manager/static/src/xml/base.xml

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="ExportTreeView-Secondary.children">
<t t-jquery="#tree-column a" t-operation="append">
<t t-extend="Export.TreeItems">
<t t-jquery=".o_tree_column" t-operation="append">
(<t t-esc="field.id"/>)
</t>
</t>

4
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):

7
base_export_manager/tests/test_ir_exports_line.py

@ -3,8 +3,8 @@
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# 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})

Loading…
Cancel
Save