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
|
* https://www.odoo.com/forum/help-1
|
||||||
|
|
||||||
Roadmap
|
Known issues / Roadmap
|
||||||
=======
|
======================
|
||||||
|
|
||||||
* ...
|
* ...
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -82,15 +81,15 @@ class ModulePrototyper(models.Model):
|
||||||
description = fields.Text(
|
description = fields.Text(
|
||||||
'Description',
|
'Description',
|
||||||
required=True,
|
required=True,
|
||||||
help=('Enter the description of your module, what it does, how to'
|
help=('Enter the description of your module, what it does, how to '
|
||||||
'install, configure and use it, the roadmap or known issues.'
|
'install, configure and use it, the roadmap or known issues. '
|
||||||
'The description will be exported in README.rst'),
|
'The description will be exported in README.rst'),
|
||||||
default=get_default_description
|
default=get_default_description
|
||||||
)
|
)
|
||||||
author = fields.Char('Author', required=True, help=('Enter your name'))
|
author = fields.Char('Author', required=True, help=('Enter your name'))
|
||||||
maintainer = fields.Char(
|
maintainer = fields.Char(
|
||||||
'Maintainer',
|
'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')
|
'maintain this module')
|
||||||
)
|
)
|
||||||
website = fields.Char('Website', help=('Enter the URL of your website'))
|
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',
|
'ir.module.module', 'module_prototyper_module_rel',
|
||||||
'module_prototyper_id', 'module_id',
|
'module_prototyper_id', 'module_id',
|
||||||
'Dependencies',
|
'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')
|
'for your module to work properly')
|
||||||
)
|
)
|
||||||
data_ids = fields.Many2many(
|
data_ids = fields.Many2many(
|
||||||
|
@ -140,34 +139,34 @@ class ModulePrototyper(models.Model):
|
||||||
field_ids = fields.Many2many(
|
field_ids = fields.Many2many(
|
||||||
'ir.model.fields', 'prototype_fields_rel',
|
'ir.model.fields', 'prototype_fields_rel',
|
||||||
'module_prototyper_id', 'field_id', 'Fields',
|
'module_prototyper_id', 'field_id', 'Fields',
|
||||||
help=('Enter the list of fields that you have created or modified'
|
help=('Enter the list of fields that you have created or modified '
|
||||||
'and want to export in this module. New models will be'
|
'and want to export in this module. New models will be '
|
||||||
'exported as long as you choose one of his fields.')
|
'exported as long as you choose one of his fields.')
|
||||||
)
|
)
|
||||||
menu_ids = fields.Many2many(
|
menu_ids = fields.Many2many(
|
||||||
'ir.ui.menu', 'prototype_menu_rel',
|
'ir.ui.menu', 'prototype_menu_rel',
|
||||||
'module_prototyper_id', 'menu_id', 'Menu Items',
|
'module_prototyper_id', 'menu_id', 'Menu Items',
|
||||||
help=('Enter the list of menu items that you have created and want'
|
help=('Enter the list of menu items that you have created and want '
|
||||||
'to export in this module. Related windows actions will be'
|
'to export in this module. Related windows actions will be '
|
||||||
'exported as well.')
|
'exported as well.')
|
||||||
)
|
)
|
||||||
view_ids = fields.Many2many(
|
view_ids = fields.Many2many(
|
||||||
'ir.ui.view', 'prototype_view_rel',
|
'ir.ui.view', 'prototype_view_rel',
|
||||||
'module_prototyper_id', 'view_id', 'Views',
|
'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.')
|
'export in this module.')
|
||||||
)
|
)
|
||||||
group_ids = fields.Many2many(
|
group_ids = fields.Many2many(
|
||||||
'res.groups', 'prototype_groups_rel',
|
'res.groups', 'prototype_groups_rel',
|
||||||
'module_prototyper_id', 'group_id', 'Groups',
|
'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.')
|
'export in this module.')
|
||||||
)
|
)
|
||||||
right_ids = fields.Many2many(
|
right_ids = fields.Many2many(
|
||||||
'ir.model.access', 'prototype_rights_rel',
|
'ir.model.access', 'prototype_rights_rel',
|
||||||
'module_prototyper_id', 'right_id',
|
'module_prototyper_id', 'right_id',
|
||||||
'Access Rights',
|
'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.')
|
'want to export in this module.')
|
||||||
)
|
)
|
||||||
rule_ids = fields.Many2many(
|
rule_ids = fields.Many2many(
|
||||||
|
|
|
@ -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,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.
|
# Install this module automatically if all dependency have been previously
|
||||||
# Used for synergetic or glue modules.
|
# 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 }},
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 %}
|
||||||
|
|
|
@ -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):
|
class {{ unprefix(name) }}(models.Model):
|
||||||
_inherit = "{{ inherit }}"
|
{% if model.state == 'base' %}
|
||||||
{% if description -%}_description = "{{ description }}"{% endif %}
|
_name = "{{ model.model }}"
|
||||||
|
{% else %}
|
||||||
|
_inherit = "{{ model.model }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if description %}
|
||||||
|
_description = "{{ description }}"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for field in fields -%}
|
{% for field in fields %}
|
||||||
{% if field.notes -%}# {{ field.notes }}{% endif %}
|
{% for line in wrap(field.notes, replace_whitespace=False) %}
|
||||||
{{ field.name }} = fields.{{ field.ttype|capitalize }}(
|
# {{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 }},
|
readonly={{ field.readonly }}
|
||||||
{% if field.size -%}size={{ field.size }},{% endif %}
|
{% if field.size %}
|
||||||
{% if field.helper -%}help=_("{{ field.helper }}"),{% endif %}
|
size={{ field.size }},
|
||||||
){% endfor %}
|
{% 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 -%}
|
{% 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 }}
|
{% if menu.action.help %}
|
||||||
</field>{% endif %}
|
<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>
|
||||||
|
|
|
@ -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 %}
|
||||||
{% for view in views -%}
|
<record id="{{ unprefix(view.name)|replace('.', '_')}}_view" model="ir.ui.view">
|
||||||
<record id="{{ view.name|replace('.', '_')}}_view" model="ir.ui.view">
|
<field name="name">{{ unprefix(view.name) }}.view</field>
|
||||||
<field name="name">{{ view.name }}.view</field>
|
<field name="model">{{ unprefix(view.model) }}</field>
|
||||||
<field name="model">{{ 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
|
{{ fixup_arch(view.arch) }}
|
||||||
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>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in New Issue