Browse Source
Improve UX for base_export_manager.
Improve UX for base_export_manager.
- Improve user instructions in README. - Require some required fields. - Allow to select models from a list. - Allow to select up to 3 fields from dynamic lists. - Improve translations. - More tests. - Translate column labels. Some methods have been renamed, so version tag is raised to 8.0.2.0.0.pull/317/head
Jairo Llopis
9 years ago
14 changed files with 377 additions and 210 deletions
-
40base_export_manager/README.rst
-
24base_export_manager/__init__.py
-
27base_export_manager/__openerp__.py
-
8base_export_manager/data/ir_exports_data.xml
-
50base_export_manager/i18n/base_exports_manager.pot
-
43base_export_manager/i18n/es.po
-
26base_export_manager/models/__init__.py
-
65base_export_manager/models/ir_exports.py
-
205base_export_manager/models/ir_exports_line.py
-
26base_export_manager/static/src/js/main.js
-
7base_export_manager/tests/__init__.py
-
28base_export_manager/tests/test_ir_exports.py
-
6base_export_manager/tests/test_ir_exports_line.py
-
32base_export_manager/views/ir_exports_view.xml
@ -1,25 +1,5 @@ |
|||
# -*- 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/>. |
|||
# |
|||
############################################################################## |
|||
# © 2015 Antiun Ingeniería S.L. - Antonio Espinosa |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import models |
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<function model="ir.exports.line" name="_install_base_export_manager"/> |
|||
|
|||
</data> |
|||
</openerp> |
@ -1,50 +0,0 @@ |
|||
# 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 "" |
@ -1,25 +1,5 @@ |
|||
# -*- 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/>. |
|||
# |
|||
############################################################################## |
|||
# © 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_line |
|||
from . import ir_exports, ir_exports_line |
@ -0,0 +1,65 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openerp import api, fields, models |
|||
|
|||
|
|||
class IrExports(models.Model): |
|||
_inherit = 'ir.exports' |
|||
|
|||
name = fields.Char(required=True) |
|||
resource = fields.Char( |
|||
required=True, |
|||
readonly=True, |
|||
help="Model's technical name.") |
|||
model_id = fields.Many2one( |
|||
"ir.model", |
|||
"Model", |
|||
required=True, |
|||
store=True, |
|||
domain=[("osv_memory", "=", False)], |
|||
compute="_compute_model_id", |
|||
inverse="_inverse_model_id", |
|||
help="Database model to export.") |
|||
|
|||
@api.multi |
|||
@api.depends("resource") |
|||
def _compute_model_id(self): |
|||
"""Get the model from the resource.""" |
|||
for s in self: |
|||
s.model_id = self._get_model_id(s.resource) |
|||
|
|||
@api.multi |
|||
def _inverse_model_id(self): |
|||
"""Get the resource from the model.""" |
|||
for s in self: |
|||
s.resource = s.model_id.model |
|||
|
|||
@api.multi |
|||
@api.onchange("resource") |
|||
def _onchange_resource(self): |
|||
"""Void fields if model is changed in a view.""" |
|||
for s in self: |
|||
s.export_fields = False |
|||
|
|||
@api.model |
|||
def _get_model_id(self, resource): |
|||
"""Return a model object from its technical name. |
|||
|
|||
:param str resource: |
|||
Technical name of the model, like ``ir.model``. |
|||
""" |
|||
return self.env["ir.model"].search([("model", "=", resource)]) |
|||
|
|||
@api.model |
|||
def create(self, vals): |
|||
"""Add new required value when missing. |
|||
|
|||
This is required because this model is created from a QWeb wizard view |
|||
that does not populate ``model_id``, and it is easier to hack here than |
|||
in the view. |
|||
""" |
|||
vals.setdefault("model_id", |
|||
self._get_model_id(vals.get("resource")).id) |
|||
return super(IrExports, self).create(vals) |
@ -1,5 +1,6 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# License AGPL-3: Antiun Ingenieria S.L. - Javier Iniesta |
|||
# See README.rst file on addon root folder for more details |
|||
# © 2015 Antiun Ingeniería S.L. - Javier Iniesta |
|||
# © 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_line |
|||
from . import test_ir_exports, test_ir_exports_line |
@ -0,0 +1,28 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from openerp.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestIrExportsCase(TransactionCase): |
|||
def test_create_with_basic_data(self): |
|||
"""Emulate creation from original form. |
|||
|
|||
This form is handled entirely client-side, and lacks some required |
|||
field values. |
|||
""" |
|||
# Emulate creation from JsonRpc, without model_id and field#_id |
|||
data = { |
|||
"name": u"Test éxport", |
|||
"resource": "ir.exports", |
|||
"export_fields": [ |
|||
[0, 0, {"name": "export_fields"}], |
|||
[0, 0, {"name": "export_fields/create_uid"}], |
|||
[0, 0, {"name": "export_fields/create_date"}], |
|||
[0, 0, {"name": "export_fields/field1_id"}], |
|||
], |
|||
} |
|||
record = self.env["ir.exports"].create(data) |
|||
|
|||
self.assertEqual(record.model_id.model, data["resource"]) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue