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
parent
d44e189797
commit
dbbd49d3e6
|
@ -61,8 +61,8 @@ For further information, please visit:
|
|||
|
||||
* https://www.odoo.com/forum/help-1
|
||||
|
||||
Roadmap
|
||||
=======
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* ...
|
||||
|
||||
|
|
|
@ -25,10 +25,9 @@ import lxml.etree
|
|||
import os
|
||||
import re
|
||||
import textwrap
|
||||
import base64
|
||||
from datetime import date
|
||||
|
||||
from collections import namedtuple
|
||||
from datetime import date
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
|
@ -82,15 +81,15 @@ class ModulePrototyper(models.Model):
|
|||
description = fields.Text(
|
||||
'Description',
|
||||
required=True,
|
||||
help=('Enter the description of your module, what it does, how to'
|
||||
'install, configure and use it, the roadmap or known issues.'
|
||||
help=('Enter the description of your module, what it does, how to '
|
||||
'install, configure and use it, the roadmap or known issues. '
|
||||
'The description will be exported in README.rst'),
|
||||
default=get_default_description
|
||||
)
|
||||
author = fields.Char('Author', required=True, help=('Enter your name'))
|
||||
maintainer = fields.Char(
|
||||
'Maintainer',
|
||||
help=('Enter the name of the person or organization who will'
|
||||
help=('Enter the name of the person or organization who will '
|
||||
'maintain this module')
|
||||
)
|
||||
website = fields.Char('Website', help=('Enter the URL of your website'))
|
||||
|
@ -120,7 +119,7 @@ class ModulePrototyper(models.Model):
|
|||
'ir.module.module', 'module_prototyper_module_rel',
|
||||
'module_prototyper_id', 'module_id',
|
||||
'Dependencies',
|
||||
help=('Enter the list of required modules that need to be installed'
|
||||
help=('Enter the list of required modules that need to be installed '
|
||||
'for your module to work properly')
|
||||
)
|
||||
data_ids = fields.Many2many(
|
||||
|
@ -140,34 +139,34 @@ class ModulePrototyper(models.Model):
|
|||
field_ids = fields.Many2many(
|
||||
'ir.model.fields', 'prototype_fields_rel',
|
||||
'module_prototyper_id', 'field_id', 'Fields',
|
||||
help=('Enter the list of fields that you have created or modified'
|
||||
'and want to export in this module. New models will be'
|
||||
help=('Enter the list of fields that you have created or modified '
|
||||
'and want to export in this module. New models will be '
|
||||
'exported as long as you choose one of his fields.')
|
||||
)
|
||||
menu_ids = fields.Many2many(
|
||||
'ir.ui.menu', 'prototype_menu_rel',
|
||||
'module_prototyper_id', 'menu_id', 'Menu Items',
|
||||
help=('Enter the list of menu items that you have created and want'
|
||||
'to export in this module. Related windows actions will be'
|
||||
help=('Enter the list of menu items that you have created and want '
|
||||
'to export in this module. Related windows actions will be '
|
||||
'exported as well.')
|
||||
)
|
||||
view_ids = fields.Many2many(
|
||||
'ir.ui.view', 'prototype_view_rel',
|
||||
'module_prototyper_id', 'view_id', 'Views',
|
||||
help=('Enter the list of views that you have created and want to'
|
||||
help=('Enter the list of views that you have created and want to '
|
||||
'export in this module.')
|
||||
)
|
||||
group_ids = fields.Many2many(
|
||||
'res.groups', 'prototype_groups_rel',
|
||||
'module_prototyper_id', 'group_id', 'Groups',
|
||||
help=('Enter the list of groups that you have created and want to'
|
||||
help=('Enter the list of groups that you have created and want to '
|
||||
'export in this module.')
|
||||
)
|
||||
right_ids = fields.Many2many(
|
||||
'ir.model.access', 'prototype_rights_rel',
|
||||
'module_prototyper_id', 'right_id',
|
||||
'Access Rights',
|
||||
help=('Enter the list of access rights that you have created and'
|
||||
help=('Enter the list of access rights that you have created and '
|
||||
'want to export in this module.')
|
||||
)
|
||||
rule_ids = fields.Many2many(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{% extends "header.template" %}
|
||||
{% block body %}
|
||||
{% if models -%}
|
||||
{% if models %}
|
||||
|
||||
from . import models
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{% extends "header.template" %}
|
||||
{% block body %}
|
||||
|
||||
{
|
||||
'name': '{{ prototype.name }}',
|
||||
'name': '{{ prototype.human_name }}',
|
||||
'version': '{{ prototype.version }}',
|
||||
'author': '{{ prototype.author }}',
|
||||
'maintainer': '{{ prototype.maintainer }}',
|
||||
|
@ -9,9 +10,9 @@
|
|||
'license': '{{ prototype.licence }}',
|
||||
|
||||
# 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
|
||||
'category': '{{ prototype.category_id.name }}',
|
||||
'category': '{{ prototype.with_context({}).category_id.name }}',{# In english please! #}
|
||||
'summary': '{{ prototype.summary }}',
|
||||
'description': """
|
||||
{{ prototype.description }}
|
||||
|
@ -23,33 +24,36 @@
|
|||
|
||||
# any module necessary for this one to work correctly
|
||||
'depends': [
|
||||
{% for dependency in prototype.dependency_ids -%}
|
||||
{% for dependency in prototype.dependency_ids %}
|
||||
'{{ dependency.name }}',
|
||||
{% endfor -%}],
|
||||
{% endfor %}
|
||||
],
|
||||
'external_dependencies': {
|
||||
'python': [],
|
||||
},
|
||||
|
||||
# always loaded
|
||||
'data': [
|
||||
{% for data_file in data_files -%}
|
||||
{% for data_file in data_files %}
|
||||
'{{ data_file }}',
|
||||
{% endfor -%}],
|
||||
{% endfor %}
|
||||
],
|
||||
# only loaded in demonstration mode
|
||||
'demo': [
|
||||
{% for demo_file in prototype.demo_ids -%}
|
||||
{% for demo_file in prototype.demo_ids %}
|
||||
'{{ demo_file.name }}',
|
||||
{% endfor -%}],
|
||||
{% endfor %}
|
||||
],
|
||||
|
||||
# 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': [],
|
||||
'css': [],
|
||||
'qweb': [],
|
||||
|
||||
'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 }},
|
||||
'application': {{ prototype.application }},
|
||||
}
|
||||
|
|
|
@ -19,4 +19,5 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{% block body %}{% endblock %}
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{% extends "header.template" %}
|
||||
{% block body %}
|
||||
{% for model in models -%}
|
||||
{% for model in models %}
|
||||
{% if loop.first %}
|
||||
|
||||
{% endif %}
|
||||
from . import {{ model }}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,22 +1,35 @@
|
|||
{% 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 %}
|
||||
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 }}"),
|
||||
required={{ field.required }},
|
||||
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 %}
|
||||
|
|
|
@ -1,24 +1,29 @@
|
|||
<?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>
|
||||
{% 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>
|
||||
</openerp>
|
||||
|
|
|
@ -2,22 +2,16 @@
|
|||
<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.view">
|
||||
<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('"', "'")|replace("<?xml version='1.0'?>", "")|replace("'x_", "'")|replace("> </field>", "/>") }}
|
||||
</field>
|
||||
</record>
|
||||
{% 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="inherit_id" ref="{{ view.inherit_id.get_xml_id(cr,1,1).values()[0] }}"/>
|
||||
<field name="arch" type="xml">
|
||||
{{ fixup_arch(view.arch) }}
|
||||
</field>
|
||||
</record>
|
||||
{% endfor %}
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue