Pedro M. Baeza
9 years ago
15 changed files with 573 additions and 0 deletions
-
60base_export_manager/README.rst
-
25base_export_manager/__init__.py
-
41base_export_manager/__openerp__.py
-
50base_export_manager/i18n/base_exports_manager.pot
-
50base_export_manager/i18n/es.po
-
25base_export_manager/models/__init__.py
-
70base_export_manager/models/ir_exports_line.py
-
BINbase_export_manager/static/description/icon.png
-
79base_export_manager/static/description/icon.svg
-
54base_export_manager/static/src/js/main.js
-
10base_export_manager/static/src/xml/base.xml
-
5base_export_manager/tests/__init__.py
-
36base_export_manager/tests/test_ir_exports_line.py
-
17base_export_manager/views/assets.xml
-
51base_export_manager/views/ir_exports_view.xml
@ -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 <https://github.com/OCA/server-tools/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 <https://github.com/OCA/server-tools/issues/new?body=module:%20base_exports_manager%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|||
|
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Antonio Espinosa <antonioea@antiun.com> |
|||
* Javier Iniesta <javieria@antiun.com> |
|||
|
|||
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. |
@ -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 <antonioea@antiun.com> |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from . import models |
@ -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 <antonioea@antiun.com> |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
{ |
|||
'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, |
|||
} |
@ -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 "" |
@ -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" |
@ -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 <antonioea@antiun.com> |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from . import ir_exports_line |
@ -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 <antonioea@antiun.com> |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
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() |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
79
base_export_manager/static/description/icon.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -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 <antonioea@antiun.com> |
|||
* # |
|||
* # 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 <http://www.gnu.org/licenses/>.
|
|||
* # |
|||
* ############################################################################## |
|||
*/ |
|||
|
|||
// 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); |
@ -0,0 +1,10 @@ |
|||
<?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-esc="field.id"/>) |
|||
</t> |
|||
</t> |
|||
|
|||
</templates> |
@ -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 |
@ -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}) |
@ -0,0 +1,17 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<!-- Add Javascript --> |
|||
<template id="assets_backend" |
|||
inherit_id="web.assets_backend" |
|||
name="Add technical name to field items" |
|||
priority="20"> |
|||
<xpath expr="." position="inside"> |
|||
<script type="text/javascript" |
|||
src="/base_exports_manager/static/src/js/main.js"/> |
|||
</xpath> |
|||
</template> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,51 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="ir_exports_action" model="ir.actions.act_window"> |
|||
<field name="name">Export Profiles</field> |
|||
<field name="res_model">ir.exports</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
</record> |
|||
|
|||
<menuitem id="ir_exports_menu" |
|||
parent="base.next_id_2" |
|||
name="Export Profiles" |
|||
action="ir_exports_action"/> |
|||
|
|||
<record id="ir_exports_tree_view" model="ir.ui.view"> |
|||
<field name="name">Export Profile tree</field> |
|||
<field name="model">ir.exports</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Export Profiles"> |
|||
<field name="name"/> |
|||
<field name="resource"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="ir_exports_form_view" model="ir.ui.view"> |
|||
<field name="name">Export Profile form</field> |
|||
<field name="model">ir.exports</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Export Profile"> |
|||
<group> |
|||
<field name="name"/> |
|||
<field name="resource"/> |
|||
</group> |
|||
<group> |
|||
<field name="export_fields" nolabel="1"> |
|||
<tree editable="bottom"> |
|||
<field name="label"/> |
|||
<field name="name"/> |
|||
<field name="sequence" invisible="1"/> |
|||
</tree> |
|||
</field> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue