Browse Source
[IMP] prototype: implementation of jinja syntax.
[IMP] prototype: implementation of jinja syntax.
[IMP] prototype: Switched to v8 api. [IMP] prototype: renamed the templates to avoid confusion with pep8 tests. [IMP] prototype: renamed some fields in prototype.py. [IMP] prototype: implemented the process to create the zip file to export. [IMP] prototype: worked on the generation of __openerp__.py and __init__.py files from the prototype. [IMP] prototype: pep8 [IMP] prototype: added more comments. [IMP] prototype: worked on fields. [IMP] prototype: implemented the generation of files from models/model_name.py.template and models/init.py.template [IMP] prototype: first work on implementation of generations of views. [IMP] prototype: improved the arch section in model_view.xml.template [IMP] prototype: Reviewed the names of many2many from plurials to name_ids. [IMP] prototype: added menus. [IMP] prototype: typo in templates/8.0/views/model_view.xml.template [IMP] prototype: improved template with adding extension to header.template to ease management of file with licence header. [IMP] prototype: prototype.prototype demo data [IMP] prototype: worked to get the views and menus properly generated. Added actions to model_menus.xml.template. [IMP] prototype: should fix pep8 in model_name.py.template.pull/107/head
Jordi Riera
10 years ago
committed by
Maxime Chambreuil
36 changed files with 815 additions and 453 deletions
-
8prototype/__openerp__.py
-
2prototype/demo/prototype.prototype.csv
-
4prototype/i18n/fr.po
-
4prototype/i18n/prototype.pot
-
8prototype/models/ir_model_fields.py
-
358prototype/models/prototype.py
-
50prototype/templates/7.0/__openerp__.py
-
8prototype/templates/7.0/data/model_name.xml
-
8prototype/templates/7.0/demo/model_name.xml
-
24prototype/templates/7.0/models/__init__.py
-
36prototype/templates/7.0/models/model_name.py
-
1prototype/templates/7.0/security/ir.model.access.csv
-
6prototype/templates/8.0/__init__.py.template
-
50prototype/templates/8.0/__openerp__.py
-
38prototype/templates/8.0/__openerp__.py.template
-
2prototype/templates/8.0/data/model_name.xml.template
-
8prototype/templates/8.0/demo/model_name.xml
-
2prototype/templates/8.0/demo/model_name.xml.template
-
6prototype/templates/8.0/header.template
-
24prototype/templates/8.0/models/__init__.py
-
6prototype/templates/8.0/models/__init__.py.template
-
34prototype/templates/8.0/models/model_name.py
-
21prototype/templates/8.0/models/model_name.py.template
-
1prototype/templates/8.0/security/ir.model.access.csv
-
4prototype/templates/8.0/security/ir.model.access.csv.template
-
10prototype/templates/8.0/security/model_name.xml
-
4prototype/templates/8.0/security/model_name.xml.template
-
24prototype/templates/8.0/views/model_menus.xml.template
-
8prototype/templates/8.0/views/model_view.xml
-
23prototype/templates/8.0/views/model_views.xml.template
-
14prototype/tests/__init__.py
-
83prototype/tests/test_prototype.py
-
83prototype/tests/test_prototype_module_export.py
-
184prototype/views/prototype_view.xml
-
120prototype/wizard/prototype_module_export.py
-
2prototype/wizard/prototype_module_export_view.xml
2
prototype/demo/prototype.prototype.csv
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,50 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Odoo, Open Source Management Solution |
|||
# This module copyright (C) $export_date $author |
|||
# (<$website>). |
|||
# |
|||
# 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': '$name', |
|||
'version': '$version', |
|||
'author': '$author', |
|||
'maintainer': '$maintainer', |
|||
'website': '$website', |
|||
'license': 'AGPL-3', |
|||
'category': '$category', |
|||
'summary': '$summary', |
|||
'description': """ |
|||
$description |
|||
|
|||
* Module exported by the prototype module for version 7.0. |
|||
* If you have any questions, please contact Savoir-faire Linux \ |
|||
(support@savoirfairelinux.com) |
|||
""", |
|||
'depends': [ |
|||
$depends |
|||
], |
|||
'external_dependencies': { |
|||
'python': [], |
|||
}, |
|||
'data': [ |
|||
$data |
|||
], |
|||
'installable': True, |
|||
'auto_install': $auto_install, |
|||
} |
@ -1,8 +0,0 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
$data |
|||
|
|||
</data> |
|||
</openerp> |
@ -1,8 +0,0 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
$demo |
|||
|
|||
</data> |
|||
</openerp> |
@ -1,24 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Odoo, Open Source Management Solution |
|||
# This module copyright (C) $generation_date $author |
|||
# (<$website>). |
|||
# |
|||
# 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.py |
|||
) |
@ -1,36 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Odoo, Open Source Management Solution |
|||
# This module copyright (C) $generation_date $author |
|||
# (<$website>). |
|||
# |
|||
# 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.osv import fields, osv |
|||
|
|||
|
|||
class $model_name(osv.osv): |
|||
_name = "$model_name" |
|||
_inherit = "$model_name" |
|||
_description = "$model_description" |
|||
|
|||
_columns = { |
|||
$model_fields |
|||
} |
|||
|
|||
_defaults = { |
|||
|
|||
} |
@ -1 +0,0 @@ |
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
@ -0,0 +1,6 @@ |
|||
{% extends "header.template" %} |
|||
{% block body %} |
|||
{% if models -%} |
|||
from . import models |
|||
{% endif %} |
|||
{% endblock %} |
@ -1,50 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Odoo, Open Source Management Solution |
|||
# This module copyright (C) $export_date $author |
|||
# (<$website>). |
|||
# |
|||
# 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': '$name', |
|||
'version': '$version', |
|||
'author': '$author', |
|||
'maintainer': '$maintainer', |
|||
'website': '$website', |
|||
'license': 'AGPL-3', |
|||
'category': '$category', |
|||
'summary': '$summary', |
|||
'description': """ |
|||
$description |
|||
|
|||
* Module exported by the prototype module for version 8.0. |
|||
* If you have any questions, please contact Savoir-faire Linux \ |
|||
(support@savoirfairelinux.com) |
|||
""", |
|||
'depends': [ |
|||
$depends |
|||
], |
|||
'external_dependencies': { |
|||
'python': [], |
|||
}, |
|||
'data': [ |
|||
$data |
|||
], |
|||
'installable': True, |
|||
'auto_install': $auto_install, |
|||
} |
@ -0,0 +1,38 @@ |
|||
{% extends "header.template" %} |
|||
{% block body %} |
|||
{ |
|||
'name': '{{ prototype.name }}', |
|||
'version': '{{ prototype.version }}', |
|||
'author': '{{ prototype.author }}', |
|||
'maintainer': '{{ prototype.maintainer }}', |
|||
'website': '{{ prototype.website }}', |
|||
'license': '{{ prototype.licence }}', |
|||
'category': '{{ prototype.category_id.name }}', |
|||
'summary': '{{ prototype.summary }}', |
|||
'description': """ |
|||
{{ prototype.description }} |
|||
|
|||
* Module exported by the prototype module for version 8.0. |
|||
* If you have any questions, please contact Savoir-faire Linux \ |
|||
(support@savoirfairelinux.com) |
|||
""", |
|||
'depends': [ |
|||
{% for dependency in prototype.dependency_ids -%} |
|||
'{{ dependency.name }}', |
|||
{% endfor -%}], |
|||
'external_dependencies': { |
|||
'python': [], |
|||
}, |
|||
'data': [ |
|||
{% for data_file in data_files -%} |
|||
'{{ data_file }}', |
|||
{% endfor -%}], |
|||
'demo': [ |
|||
{% for demo_file in prototype.demo_ids -%} |
|||
'{{ demo_file.name }}', |
|||
{% endfor -%}], |
|||
'installable': True, |
|||
'auto_install': {{ prototype.auto_install }}, |
|||
'application': {{ prototype.application }}, |
|||
} |
|||
{% endblock %} |
@ -1,8 +0,0 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
$demo |
|||
|
|||
</data> |
|||
</openerp> |
@ -1,24 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Odoo, Open Source Management Solution |
|||
# This module copyright (C) $generation_date $author |
|||
# (<$website>). |
|||
# |
|||
# 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.py |
|||
) |
@ -0,0 +1,6 @@ |
|||
{% extends "header.template" %} |
|||
{% block body %} |
|||
{% for model in models -%} |
|||
from . import {{ model }} |
|||
{% endfor %} |
|||
{% endblock %} |
@ -1,34 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Odoo, Open Source Management Solution |
|||
# This module copyright (C) $generation_date $author |
|||
# (<$website>). |
|||
# |
|||
# 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.osv import fields, osv |
|||
|
|||
|
|||
class $model_name(osv.osv): |
|||
_name = "$model_name" |
|||
_inherit = "$model_name" |
|||
_description = "$model_description" |
|||
|
|||
$model_fields |
|||
|
|||
_defaults = { |
|||
|
|||
} |
@ -0,0 +1,21 @@ |
|||
{% extends "header.template" %} |
|||
{% block body %} |
|||
from openerp import models, fields |
|||
from openerp.tools.translate import _ |
|||
|
|||
|
|||
class {{ name }}(models.Model): |
|||
_inherit = "{{ inherit }}" |
|||
{% if description %}_description = "{{ description }}"{% endif %} |
|||
|
|||
{% for field in fields -%} |
|||
{{ field.name }} = fields.{{ field.ttype|capitalize }}( |
|||
string=_("{{ field.field_description }}"), |
|||
required={{ field.required }}, |
|||
translate={{ field.translate }}, |
|||
readonly={{ field.readonly }}, |
|||
help=_('{{ field.notes }}'), |
|||
) |
|||
{% endfor %} |
|||
|
|||
{% endblock %} |
@ -1 +0,0 @@ |
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
@ -0,0 +1,4 @@ |
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
|||
{% for rule in access_rules %} |
|||
{{ rule.id }},{{ rule.name }},{{ rule.model_id.id }},{{ rule.group_id.id }},{{ rule.perm_write }},{{ rule.perm_write }},{{ rule.perm_create }},{{ rule.perm_unlink }} |
|||
{% endfor %} |
@ -1,10 +0,0 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
$groups |
|||
|
|||
$rules |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,24 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
{% for menu in menus -%} |
|||
<record id="action_{{ menu.action.name }}_{{ menu.action.view_type }}_view" model="{{ menu.action.type }}"> |
|||
<field name="name">{{ menu.action.name }}</field> |
|||
<field name="type">{{ menu.action.type }}</field> |
|||
<field name="res_model">{{ menu.action.res_model }}</field> |
|||
<field name="view_type">{{ menu.action.view_type }}</field> |
|||
<field name="view_mode">{{ menu.action.view_mode }}</field> |
|||
{% if menu.action.help %}<field name="help" type="html">{{ menu.action.help }} |
|||
</field>{% endif %} |
|||
</record> |
|||
|
|||
<menuitem action="action_{{ menu.action.name }}_{{ menu.action.view_type }}_view" |
|||
name="{{ menu.name }}" |
|||
id="menu_action_{{ menu.name|replace('.', '_') }}_{{ menu.action.view_type }}" |
|||
{% if menu.parent_id %}parent="{{ menu.parent_id.get_xml_id(cr,1,1).values()[0] }}"{% endif %} |
|||
sequence="{{ menu.sequence }}" |
|||
groups="{% for group in menu.groups_id %}{{ group.get_xml_id(cr,1,1).values()[0] }},{% endfor %}" |
|||
/> |
|||
{% endfor -%} |
|||
</data> |
|||
</openerp> |
@ -1,8 +0,0 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
$views |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
<!-- TODO: put here a reminder on what to do at the first edition --> |
|||
|
|||
{% for view in views %} |
|||
<record id="{{ view.name|replace('.', '_')}}_view" model="ir.ui.model"> |
|||
<field name="name">{{ view.name }}.view</field> |
|||
<field name="model">{{ view.model }}</field> |
|||
<field name="view_type">{{ view.type }}</field> |
|||
<field name="inherit_id" ref="{{ view.inherit_id.get_xml_id(cr,1,1).values()[0] }}"/> |
|||
<field name="arch" type="xml"> |
|||
{# the arch given by odoo start with an xml tag that |
|||
will break the xml tree we build. |
|||
Be careful, custom field have a x_ prefix that has to be |
|||
removed |
|||
#} |
|||
{{ view.arch|replace('<?xml version="1.0"?>', '')|replace('"x_', '"') }} |
|||
</field> |
|||
</record> |
|||
{% endfor %} |
|||
</data> |
|||
</openerp> |
@ -0,0 +1,83 @@ |
|||
# -*- encoding: utf-8 -*- # |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2013 Savoir-faire Linux |
|||
# (<http://www.savoirfairelinux.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 jinja2 import Environment |
|||
from jinja2.exceptions import TemplateNotFound |
|||
from openerp.tests import common |
|||
|
|||
|
|||
class test_prototype(common.TransactionCase): |
|||
def setUp(self): |
|||
super(test_prototype, self).setUp() |
|||
self.main_model = self.env['prototype'] |
|||
self.module_category_model = self.env['ir.module.category'] |
|||
self.module_module_model = self.env['ir.module.module'] |
|||
|
|||
self.prototype = self.main_model.create({ |
|||
'name': 't_name', |
|||
'category_id': self.module_category_model.browse(1).id, |
|||
'human_name': 't_human_name', |
|||
'summary': 't_summary', |
|||
'description': 't_description', |
|||
'author': 't_author', |
|||
'maintainer': 't_maintainer', |
|||
'website': 't_website', |
|||
'dependencies': [(6, 0, [1, 2, 3, 4])], |
|||
}) |
|||
self.api_version = '8.0' |
|||
|
|||
def test_generate_files_assert_if_no_env(self): |
|||
self.assertRaises( |
|||
AssertionError, |
|||
self.prototype.generate_files |
|||
) |
|||
|
|||
def test_generate_files(self): |
|||
"""Test generate_files returns a tuple.""" |
|||
self.prototype.set_jinja_env(self.api_version) |
|||
details = self.prototype.generate_files() |
|||
self.assertIsInstance(details, list) |
|||
# namedtuples in tuple |
|||
for file_details in details: |
|||
self.assertIsInstance(file_details, tuple) |
|||
self.assertIsInstance(file_details.filename, basestring) |
|||
self.assertIsInstance(file_details.filecontent, basestring) |
|||
|
|||
def test_generate_files_raise_templatenotfound_if_not_found(self): |
|||
self.prototype.set_jinja_env('t_api_version') |
|||
self.assertRaises( |
|||
TemplateNotFound, |
|||
self.prototype.generate_files |
|||
) |
|||
|
|||
def test_set_env(self): |
|||
"""test the jinja2 environment is set.""" |
|||
self.assertIsNone(self.prototype._env) |
|||
self.prototype.set_jinja_env(self.api_version) |
|||
self.assertIsInstance( |
|||
self.prototype._env, Environment |
|||
) |
|||
|
|||
def test_friendly_name_return(self): |
|||
"""Test if the returns match the pattern.""" |
|||
name = 'res.partner' |
|||
self.assertEqual( |
|||
self.prototype.friendly_name(name), |
|||
name.replace('.', '_') |
|||
) |
@ -0,0 +1,83 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
# ############################################################################# |
|||
# |
|||
# OpenERP, Open Source Management Solution |
|||
# This module copyright (C) 2010 - 2014 Savoir-faire Linux |
|||
# (<http://www.savoirfairelinux.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.tests import common |
|||
import zipfile |
|||
import StringIO |
|||
|
|||
|
|||
class test_prototype_module_export(common.TransactionCase): |
|||
def setUp(self): |
|||
super(test_prototype_module_export, self).setUp() |
|||
self.main_model = self.env['prototype.module.export'] |
|||
self.prototype_model = self.env['prototype'] |
|||
self.module_category_model = self.env[ |
|||
'ir.module.category' |
|||
] |
|||
|
|||
self.prototype = self.prototype_model.create({ |
|||
'name': 't_name', |
|||
'category_id': self.module_category_model.browse(1).id, |
|||
'human_name': 't_human_name', |
|||
'summary': 't_summary', |
|||
'description': 't_description', |
|||
'author': 't_author', |
|||
'maintainer': 't_maintainer', |
|||
'website': 't_website', |
|||
}) |
|||
|
|||
self.exporter = self.main_model.create({'name': 't_name'}) |
|||
|
|||
def test_action_export_assert_for_wrong_active_model(self): |
|||
"""Test if the assertion raises.""" |
|||
exporter = self.main_model.with_context( |
|||
active_model='t_active_model' |
|||
).create({}) |
|||
self.assertRaises( |
|||
AssertionError, |
|||
exporter.action_export, |
|||
[exporter.id], |
|||
) |
|||
|
|||
def test_action_export_update_wizard(self): |
|||
"""Test if the wizard is updated during the process.""" |
|||
exporter = self.main_model.with_context( |
|||
active_model=self.prototype_model._name, |
|||
active_id=self.prototype.id |
|||
).create({}) |
|||
exporter.action_export(exporter.id) |
|||
self.assertEqual(exporter.state, 'get') |
|||
self.assertEqual(exporter.name, '{}.zip'.format(self.prototype.name)) |
|||
|
|||
def test_zip_files_returns_tuple(self): |
|||
"""Test the method return of the method that generate the zip file.""" |
|||
file_details = ( |
|||
('test.txt', 'generated'), |
|||
) |
|||
ret = self.main_model.zip_files(file_details) |
|||
self.assertIsInstance(ret, tuple) |
|||
self.assertIsInstance( |
|||
ret.zip_file, zipfile.ZipFile |
|||
) |
|||
|
|||
self.assertIsInstance( |
|||
ret.stringIO, StringIO.StringIO |
|||
) |
@ -1,97 +1,103 @@ |
|||
<?xml version="1.0"?> |
|||
<openerp> |
|||
<data> |
|||
<data> |
|||
|
|||
<record id="view_prototype_tree" model="ir.ui.view"> |
|||
<field name="name">prototype.tree</field> |
|||
<field name="model">prototype</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Prototype"> |
|||
<field name="name"/> |
|||
<field name="shortdesc"/> |
|||
<field name="summary"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
<record id="view_prototype_tree" model="ir.ui.view"> |
|||
<field name="name">prototype.tree</field> |
|||
<field name="model">prototype</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Prototype"> |
|||
<field name="human_name"/> |
|||
<field name="name"/> |
|||
<field name="summary"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="view_prototype_form" model="ir.ui.view"> |
|||
<field name="name">prototype.form</field> |
|||
<field name="model">prototype</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Module"> |
|||
<link rel="stylesheet" href="/base/static/src/css/description.css"/> |
|||
<sheet> |
|||
<field name="icon_image" widget="image" class="oe_avatar oe_left"/> |
|||
<div class="oe_title"> |
|||
<h1><field name="summary"/></h1> |
|||
<div> |
|||
<button name="%(button_module_export_action)d" string="Export" type="action"/> |
|||
</div> |
|||
</div> |
|||
<group> |
|||
<group> |
|||
<field name="name"/> |
|||
<field name="shortdesc"/> |
|||
<field name="category_id"/> |
|||
<field name="version"/> |
|||
</group> |
|||
<group> |
|||
<field name="author"/> |
|||
<field name="website" widget="url"/> |
|||
<field name="maintainer"/> |
|||
<field name="auto_install"/> |
|||
</group> |
|||
</group> |
|||
<notebook> |
|||
<page string="Description"> |
|||
<field name="description"/> |
|||
</page> |
|||
<page string="Dependencies"> |
|||
<field name="depends"/> |
|||
</page> |
|||
<page string="Data & Demo"> |
|||
<label for="data"/> |
|||
<field name="data"/> |
|||
<label for="demo"/> |
|||
<field name="demo"/> |
|||
</page> |
|||
<page string="Models"> |
|||
<label for="fields"/> |
|||
<field name="fields" domain="[('state', '=', 'manual')]"/> |
|||
</page> |
|||
<page string="Interface"> |
|||
<label for="menu"/> |
|||
<field name="menu"/> |
|||
<label for="views"/> |
|||
<field name="views"/> |
|||
</page> |
|||
<page string="Security"> |
|||
<label for="groups"/> |
|||
<field name="groups"/> |
|||
<label for="rights"/> |
|||
<field name="rights"/> |
|||
<label for="rules"/> |
|||
<field name="rules"/> |
|||
</page> |
|||
</notebook> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
<record id="view_prototype_form" model="ir.ui.view"> |
|||
<field name="name">prototype.form</field> |
|||
<field name="model">prototype</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Module"> |
|||
<link rel="stylesheet" |
|||
href="/base/static/src/css/description.css"/> |
|||
<sheet> |
|||
<field name="icon_image" widget="image" |
|||
class="oe_avatar oe_left"/> |
|||
<div class="oe_title"> |
|||
<h1> |
|||
<field name="human_name"/> |
|||
</h1> |
|||
<div> |
|||
<button name="%(button_module_export_action)d" |
|||
string="Export" type="action"/> |
|||
</div> |
|||
</div> |
|||
<group> |
|||
<group> |
|||
<field name="name"/> |
|||
<field name="summary"/> |
|||
<field name="category_id"/> |
|||
<field name="version"/> |
|||
</group> |
|||
<group> |
|||
<field name="author"/> |
|||
<field name="website" widget="url"/> |
|||
<field name="maintainer"/> |
|||
<field name="auto_install"/> |
|||
<field name="application"/> |
|||
</group> |
|||
</group> |
|||
<notebook> |
|||
<page string="Description"> |
|||
<field name="description"/> |
|||
</page> |
|||
<page string="Dependencies"> |
|||
<field name="dependency_ids"/> |
|||
</page> |
|||
<page string="Data & Demo"> |
|||
<label for="data_ids"/> |
|||
<field name="data_ids"/> |
|||
<label for="demo_ids"/> |
|||
<field name="demo_ids"/> |
|||
</page> |
|||
<page string="Fields"> |
|||
<label for="field_ids"/> |
|||
<field name="field_ids"/> |
|||
</page> |
|||
<page string="Interface"> |
|||
<label for="menu_ids"/> |
|||
<field name="menu_ids"/> |
|||
<label for="view_ids"/> |
|||
<field name="view_ids"/> |
|||
</page> |
|||
<page string="Security"> |
|||
<label for="group_ids"/> |
|||
<field name="group_ids"/> |
|||
<label for="right_ids"/> |
|||
<field name="right_ids"/> |
|||
<label for="rule_ids"/> |
|||
<field name="rule_ids"/> |
|||
</page> |
|||
</notebook> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="open_prototype_list" model="ir.actions.act_window"> |
|||
<field name="name">Prototype</field> |
|||
<field name="res_model">prototype</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="view_id" ref="view_prototype_tree"/> |
|||
</record> |
|||
<record id="open_prototype_list" model="ir.actions.act_window"> |
|||
<field name="name">Prototype</field> |
|||
<field name="res_model">prototype</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
<field name="view_id" ref="view_prototype_tree"/> |
|||
</record> |
|||
|
|||
<menuitem id="menu_open_prototype" |
|||
action="open_prototype_list" |
|||
parent="base.menu_management" |
|||
sequence="30" |
|||
groups="base.group_system"/> |
|||
<menuitem id="menu_open_prototype" |
|||
action="open_prototype_list" |
|||
parent="base.menu_management" |
|||
sequence="30" |
|||
groups="base.group_system"/> |
|||
|
|||
</data> |
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue