Browse Source
fix template description being indented
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 spacespull/107/head
Vincent Vinet
10 years ago
committed by
Maxime Chambreuil
9 changed files with 98 additions and 78 deletions
-
4module_prototyper/models/default_description.py
-
25module_prototyper/models/module_prototyper.py
-
3module_prototyper/templates/8.0/__init__.py.template
-
28module_prototyper/templates/8.0/__openerp__.py.template
-
3module_prototyper/templates/8.0/header.template
-
5module_prototyper/templates/8.0/models/__init__.py.template
-
35module_prototyper/templates/8.0/models/model_name.py.template
-
41module_prototyper/templates/8.0/views/model_menus.xml.template
-
26module_prototyper/templates/8.0/views/model_views.xml.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 %} |
@ -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 %} |
@ -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 %} |
@ -1,24 +1,29 @@ |
|||||
<?xml version="1.0"?> |
<?xml version="1.0"?> |
||||
<openerp> |
<openerp> |
||||
<data> |
<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> |
|
||||
|
{% for menu in menus %} |
||||
|
<record id="action_{{ menu.action.name }}_{{ menu.action.view_type }}_view" model="{{ menu.action.type }}"> |
||||
|
<field name="name">{{ unprefix(menu.action.name) }}</field> |
||||
|
<field name="type">{{ menu.action.type }}</field> |
||||
|
<field name="res_model">{{ unprefix(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 -%} |
|
||||
|
<menuitem action="action_{{ unprefix(menu.action.name) }}_{{ menu.action.view_type }}_view" |
||||
|
name="{{ menu.name }}" |
||||
|
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 %} |
||||
|
sequence="{{ menu.sequence }}" |
||||
|
groups="{% for group in menu.groups_id %}{{ group.get_xml_id(cr,1,1).values()[0] }},{% endfor %}" |
||||
|
/> |
||||
|
{% if not loop.last %} |
||||
|
|
||||
|
{% endif %} |
||||
|
{% endfor %} |
||||
</data> |
</data> |
||||
</openerp> |
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue