mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 17:52:01 +02:00
17.0 vanilla
This commit is contained in:
parent
2e65bf056a
commit
df627a6bba
328 changed files with 578149 additions and 759311 deletions
|
|
@ -32,10 +32,20 @@ class Scaffold(Command):
|
|||
sys.exit(parser.print_help())
|
||||
args = parser.parse_args(args=cmdargs)
|
||||
|
||||
if args.template.id == 'l10n_payroll':
|
||||
name_split = args.name.split('-')
|
||||
params = {
|
||||
'name': name_split[0],
|
||||
'code': name_split[1]
|
||||
}
|
||||
else:
|
||||
params = {'name': args.name}
|
||||
|
||||
args.template.render_to(
|
||||
snake(args.name),
|
||||
directory(args.dest, create=True),
|
||||
{'name': args.name})
|
||||
params=params,
|
||||
)
|
||||
|
||||
def epilog(self):
|
||||
return "Built-in templates available are: %s" % ', '.join(
|
||||
|
|
@ -109,11 +119,14 @@ class template(object):
|
|||
"""
|
||||
# overwrite with local
|
||||
for path, content in self.files():
|
||||
path = env.from_string(path).render(params)
|
||||
local = os.path.relpath(path, self.path)
|
||||
# strip .template extension
|
||||
root, ext = os.path.splitext(local)
|
||||
if ext == '.template':
|
||||
local = root
|
||||
if self.id == "l10n_payroll":
|
||||
modname = f"l10n_{params['code']}_hr_payroll"
|
||||
dest = os.path.join(directory, modname, local)
|
||||
destdir = os.path.dirname(dest)
|
||||
if not os.path.exists(destdir):
|
||||
|
|
@ -126,6 +139,7 @@ class template(object):
|
|||
env.from_string(content.decode('utf-8'))\
|
||||
.stream(params or {})\
|
||||
.dump(f, encoding='utf-8')
|
||||
f.write(b'\n')
|
||||
|
||||
def die(message, code=1):
|
||||
print(message, file=sys.stderr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue