Browse Source

fix template description being indented

[FIX] Use human name and english category name for manifest

[IMP] multi line notes, unprefix names, pep8 py files

[IMP] whitespace cleanup in templates

[FIX] base models get _name, custom get _inherit

add missing spaces
pull/107/head
Vincent Vinet 10 years ago
committed by Maxime Chambreuil
parent
commit
dbbd49d3e6
  1. 4
      module_prototyper/models/default_description.py
  2. 3
      module_prototyper/models/module_prototyper.py
  3. 3
      module_prototyper/templates/8.0/__init__.py.template
  4. 28
      module_prototyper/templates/8.0/__openerp__.py.template
  5. 3
      module_prototyper/templates/8.0/header.template
  6. 5
      module_prototyper/templates/8.0/models/__init__.py.template
  7. 35
      module_prototyper/templates/8.0/models/model_name.py.template
  8. 21
      module_prototyper/templates/8.0/views/model_menus.xml.template
  9. 16
      module_prototyper/templates/8.0/views/model_views.xml.template

4
module_prototyper/models/default_description.py

@ -61,8 +61,8 @@ For further information, please visit:
* https://www.odoo.com/forum/help-1 * https://www.odoo.com/forum/help-1
Roadmap
=======
Known issues / Roadmap
======================
* ... * ...

3
module_prototyper/models/module_prototyper.py

@ -25,10 +25,9 @@ import lxml.etree
import os import os
import re import re
import textwrap import textwrap
import base64
from datetime import date
from collections import namedtuple from collections import namedtuple
from datetime import date
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader

3
module_prototyper/templates/8.0/__init__.py.template

@ -1,6 +1,7 @@
{% extends "header.template" %} {% extends "header.template" %}
{% block body %} {% block body %}
{% if models -%}
{% if models %}
from . import models from . import models
{% endif %} {% endif %}
{% endblock %} {% endblock %}

28
module_prototyper/templates/8.0/__openerp__.py.template

@ -1,7 +1,8 @@
{% extends "header.template" %} {% extends "header.template" %}
{% block body %} {% block body %}
{ {
'name': '{{ prototype.name }}',
'name': '{{ prototype.human_name }}',
'version': '{{ prototype.version }}', 'version': '{{ prototype.version }}',
'author': '{{ prototype.author }}', 'author': '{{ prototype.author }}',
'maintainer': '{{ prototype.maintainer }}', 'maintainer': '{{ prototype.maintainer }}',
@ -9,9 +10,9 @@
'license': '{{ prototype.licence }}', 'license': '{{ prototype.licence }}',
# Categories can be used to filter modules in modules listing # Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml # noqa
# for the full list # for the full list
'category': '{{ prototype.category_id.name }}',
'category': '{{ prototype.with_context({}).category_id.name }}',{# In english please! #}
'summary': '{{ prototype.summary }}', 'summary': '{{ prototype.summary }}',
'description': """ 'description': """
{{ prototype.description }} {{ prototype.description }}
@ -23,33 +24,36 @@
# any module necessary for this one to work correctly # any module necessary for this one to work correctly
'depends': [ 'depends': [
{% for dependency in prototype.dependency_ids -%}
{% for dependency in prototype.dependency_ids %}
'{{ dependency.name }}', '{{ dependency.name }}',
{% endfor -%}],
{% endfor %}
],
'external_dependencies': { 'external_dependencies': {
'python': [], 'python': [],
}, },
# always loaded # always loaded
'data': [ 'data': [
{% for data_file in data_files -%}
{% for data_file in data_files %}
'{{ data_file }}', '{{ data_file }}',
{% endfor -%}],
{% endfor %}
],
# only loaded in demonstration mode # only loaded in demonstration mode
'demo': [ 'demo': [
{% for demo_file in prototype.demo_ids -%}
{% for demo_file in prototype.demo_ids %}
'{{ demo_file.name }}', '{{ demo_file.name }}',
{% endfor -%}],
{% endfor %}
],
# used for Javascript Web CLient Testing with QUnit / PhantomJS # used for Javascript Web CLient Testing with QUnit / PhantomJS
# https://www.odoo.com/documentation/8.0/reference/javascript.html#testing-in-odoo-web-client
# https://www.odoo.com/documentation/8.0/reference/javascript.html#testing-in-odoo-web-client # noqa
'js': [], 'js': [],
'css': [], 'css': [],
'qweb': [], 'qweb': [],
'installable': True, 'installable': True,
# Install this module automatically if all dependency have been previously and independently installed.
# Used for synergetic or glue modules.
# Install this module automatically if all dependency have been previously
# and independently installed. Used for synergetic or glue modules.
'auto_install': {{ prototype.auto_install }}, 'auto_install': {{ prototype.auto_install }},
'application': {{ prototype.application }}, 'application': {{ prototype.application }},
} }

3
module_prototyper/templates/8.0/header.template

@ -19,4 +19,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
{% block body %}{% endblock %}
{% block body %}
{% endblock %}

5
module_prototyper/templates/8.0/models/__init__.py.template

@ -1,6 +1,9 @@
{% extends "header.template" %} {% extends "header.template" %}
{% block body %} {% block body %}
{% for model in models -%}
{% for model in models %}
{% if loop.first %}
{% endif %}
from . import {{ model }} from . import {{ model }}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

35
module_prototyper/templates/8.0/models/model_name.py.template

@ -1,22 +1,35 @@
{% extends "header.template" %} {% extends "header.template" %}
{% block body %} {% block body %}
from openerp import models, fields from openerp import models, fields
from openerp.tools.translate import _ from openerp.tools.translate import _
class {{ name }}(models.Model):
_inherit = "{{ inherit }}"
{% if description -%}_description = "{{ description }}"{% endif %}
class {{ unprefix(name) }}(models.Model):
{% if model.state == 'base' %}
_name = "{{ model.model }}"
{% else %}
_inherit = "{{ model.model }}"
{% endif %}
{% if description %}
_description = "{{ description }}"
{% endif %}
{% for field in fields -%}
{% if field.notes -%}# {{ field.notes }}{% endif %}
{{ field.name }} = fields.{{ field.ttype|capitalize }}(
{% for field in fields %}
{% for line in wrap(field.notes, replace_whitespace=False) %}
# {{line}}
{% endfor %}
{{ unprefix(field.name) }} = fields.{{ field.ttype|capitalize }}(
string=_("{{ field.field_description }}"), string=_("{{ field.field_description }}"),
required={{ field.required }}, required={{ field.required }},
translate={{ field.translate }}, translate={{ field.translate }},
readonly={{ field.readonly }},
{% if field.size -%}size={{ field.size }},{% endif %}
{% if field.helper -%}help=_("{{ field.helper }}"),{% endif %}
){% endfor %}
readonly={{ field.readonly }}
{% if field.size %}
size={{ field.size }},
{% endif %}
{% if field.helper %}
help=_("{{ field.helper }}"),
{% endif %}
)
{% endfor %}
{% endblock %} {% endblock %}

21
module_prototyper/templates/8.0/views/model_menus.xml.template

@ -1,24 +1,29 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<openerp> <openerp>
<data> <data>
{% for menu in menus -%}
{% for menu in menus %}
<record id="action_{{ menu.action.name }}_{{ menu.action.view_type }}_view" model="{{ menu.action.type }}"> <record id="action_{{ menu.action.name }}_{{ menu.action.view_type }}_view" model="{{ menu.action.type }}">
<field name="name">{{ menu.action.name }}</field>
<field name="name">{{ unprefix(menu.action.name) }}</field>
<field name="type">{{ menu.action.type }}</field> <field name="type">{{ menu.action.type }}</field>
<field name="res_model">{{ menu.action.res_model }}</field>
<field name="res_model">{{ unprefix(menu.action.res_model) }}</field>
<field name="view_type">{{ menu.action.view_type }}</field> <field name="view_type">{{ menu.action.view_type }}</field>
<field name="view_mode">{{ menu.action.view_mode }}</field> <field name="view_mode">{{ menu.action.view_mode }}</field>
{% if menu.action.help %}<field name="help" type="html">{{ menu.action.help }}
</field>{% endif %}
{% if menu.action.help %}
<field name="help" type="html">{{ menu.action.help }}
</field>
{% endif %}
</record> </record>
<menuitem action="action_{{ menu.action.name }}_{{ menu.action.view_type }}_view"
<menuitem action="action_{{ unprefix(menu.action.name) }}_{{ menu.action.view_type }}_view"
name="{{ menu.name }}" name="{{ menu.name }}"
id="menu_action_{{ menu.name|replace('.', '_') }}_{{ menu.action.view_type }}"
id="menu_action_{{ unprefix(menu.name)|replace('.', '_') }}_{{ menu.action.view_type }}"
{% if menu.parent_id %}parent="{{ menu.parent_id.get_xml_id(cr,1,1).values()[0] }}"{% endif %} {% if menu.parent_id %}parent="{{ menu.parent_id.get_xml_id(cr,1,1).values()[0] }}"{% endif %}
sequence="{{ menu.sequence }}" sequence="{{ menu.sequence }}"
groups="{% for group in menu.groups_id %}{{ group.get_xml_id(cr,1,1).values()[0] }},{% endfor %}" groups="{% for group in menu.groups_id %}{{ group.get_xml_id(cr,1,1).values()[0] }},{% endfor %}"
/> />
{% endfor -%}
{% if not loop.last %}
{% endif %}
{% endfor %}
</data> </data>
</openerp> </openerp>

16
module_prototyper/templates/8.0/views/model_views.xml.template

@ -2,20 +2,14 @@
<openerp> <openerp>
<data> <data>
<!-- TODO: put here a reminder on what to do at the first edition --> <!-- 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.view">
<field name="name">{{ view.name }}.view</field>
<field name="model">{{ view.model }}</field>
{% for view in views %}
<record id="{{ unprefix(view.name)|replace('.', '_')}}_view" model="ir.ui.view">
<field name="name">{{ unprefix(view.name) }}.view</field>
<field name="model">{{ unprefix(view.model) }}</field>
<field name="view_type">{{ view.type }}</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="inherit_id" ref="{{ view.inherit_id.get_xml_id(cr,1,1).values()[0] }}"/>
<field name="arch" type="xml"> <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('"', "'")|replace("<?xml version='1.0'?>", "")|replace("'x_", "'")|replace("> </field>", "/>") }}
{{ fixup_arch(view.arch) }}
</field> </field>
</record> </record>
{% endfor %} {% endfor %}

Loading…
Cancel
Save