diff --git a/openerp/cli/scaffold.py b/openerp/cli/scaffold.py
index 0cf7b66fcf2..d67bef3beca 100644
--- a/openerp/cli/scaffold.py
+++ b/openerp/cli/scaffold.py
@@ -69,6 +69,8 @@ class Scaffold(Command):
scaffold.add_controller(args.controller)
if args.web:
scaffold.add_webclient_structure()
+ if args.theme:
+ scaffold.add_theme_structure()
class ScaffoldModule(object):
"""
@@ -102,7 +104,7 @@ class ScaffoldModule(object):
if_exists='append', model=model)
self.append_manifest_list('data', 'security/ir.model.access.csv')
- demo_file = '%s_demo.xml' % self.module
+ demo_file = 'data/%s_demo.xml' % self.module
self.append_xml_data('record.jinja2', self.path(demo_file),
model=model)
self.append_manifest_list('demo', demo_file)
@@ -126,6 +128,13 @@ class ScaffoldModule(object):
self.render_file('webclient_%s.jinja2' % ext,
self.path('static', 'src', ext, prefix % ext))
+ def add_theme_structure(self):
+ self.append_manifest_list('depends', 'website')
+ css_file = '%s_theme.css' % self.module
+ self.render_file('theme_css.jinja2', self.path('static', 'src', 'css', css_file))
+ theme_file = '%s_theme.xml' % self.module
+ self.append_xml_data('theme_xml.jinja2', self.path('views', theme_file), skip_if_exist=True)
+
def has_import(self, initfile, module):
with open(initfile, 'r') as f:
for imp in ast.parse(f.read()).body:
@@ -183,9 +192,11 @@ class ScaffoldModule(object):
with open(dest, mode) as f:
f.write(content)
- def append_xml_data(self, template, dest, **kwargs):
+ def append_xml_data(self, template, dest, skip_if_exist=False, **kwargs):
if not os.path.exists(dest):
self.render_file('xmldata.jinja2', dest, **kwargs)
+ elif skip_if_exist:
+ warn("File `%s` already exists. Skipping it..." % dest)
with open(dest, 'r') as f:
data = f.read()
m = re.search('(^\s*)?', data, re.MULTILINE)
diff --git a/openerp/cli/scaffold/theme_css.jinja2 b/openerp/cli/scaffold/theme_css.jinja2
new file mode 100644
index 00000000000..cd42d262c53
--- /dev/null
+++ b/openerp/cli/scaffold/theme_css.jinja2
@@ -0,0 +1,4 @@
+@charset "utf-8";
+.{{ module }} {
+ background: white;
+}
diff --git a/openerp/cli/scaffold/theme_xml.jinja2 b/openerp/cli/scaffold/theme_xml.jinja2
new file mode 100644
index 00000000000..7ed3a637533
--- /dev/null
+++ b/openerp/cli/scaffold/theme_xml.jinja2
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/openerp/cli/start.py b/openerp/cli/start.py
index 39e008293f7..3ff291e9dc5 100644
--- a/openerp/cli/start.py
+++ b/openerp/cli/start.py
@@ -30,13 +30,15 @@ class Start(Command):
help="Specify the database name (default to project's directory name")
- #openerp.tools.config.parse_config(args)
args, unknown = parser.parse_known_args(args=cmdargs)
project_path = os.path.abspath(os.path.expanduser(os.path.expandvars(args.path)))
module_root = get_module_root(project_path)
+ db_name = None
if module_root:
- # go to the parent's directory of the module root if any
+ # started in a module so we choose this module name for database
+ db_name = project_path.split(os.path.sep)[-1]
+ # go to the parent's directory of the module root
project_path = os.path.abspath(os.path.join(project_path, os.pardir))
# check if one of the subfolders has at least one module
@@ -46,8 +48,7 @@ class Start(Command):
"in your project's directory or use `--path` argument" % project_path)
if not args.db_name:
- # Use the module's name if only one module found else the name of parent folder
- args.db_name = mods[0] if len(mods) == 1 else project_path.split(os.path.sep)[-1]
+ args.db_name = db_name or project_path.split(os.path.sep)[-1]
# TODO: forbid some database names ? eg template1, ...
try:
_create_empty_database(args.db_name)
@@ -61,11 +62,12 @@ class Start(Command):
cmdargs.append('--addons-path=%s' % project_path)
if '--db-filter' not in cmdargs:
cmdargs.append('--db-filter=^%s$' % args.db_name)
+ # Not sure we should auto install the module
+ # the user should use $ odoo start -i
# if '-i' not in cmdargs and '--init' not in cmdargs:
# # Install all modules of projects even if already installed
# cmdargs.extend(('-i', ','.join(mods)))
- # FIXME: how to redo config ?
main(cmdargs)
def die(message, code=1):