Пример #1
0
def post_render_addon(configurator):
    category_list = [
        "access",
        "barcode",
        "mail",
        "misc",
        "pos",
        "saas",
        "stock",
        "telegram",
        "website",
        "website_sale",
    ]
    variables = configurator.variables
    configurator.target_directory += "/" + variables["addon.technical_name"]
    if variables["addon.dependency"]:
        for mod in variables["addon.dependency"].split(', '):
            _insert_manifest_item(configurator, "depends", mod)
    # Handle icons in depends of technical_category
    _rm_suffix(
        "." + variables["addon.technical_category"],
        configurator,
        "static/description/icon.png." + variables["addon.technical_category"],
    )
    category_list.remove(variables["addon.technical_category"])
    for ctgr in category_list:
        _delete_file(configurator, "static/description/icon.png." + ctgr)
    # show message if any
    show_message(configurator)
Пример #2
0
def post_render_model(configurator):
    variables = configurator.variables
    # make sure the models package is imported from the addon root
    _add_local_import(configurator, '', 'models')
    # add new model import in __init__.py
    _add_local_import(configurator, 'models',
                      variables['model.name_underscored'])
    # views
    view_path = 'views/{}.xml'.format(variables['model.name_underscored'])
    if _model_has_view(variables):
        _insert_manifest_item(configurator, 'data', view_path)
    else:
        _delete_file(configurator, view_path)
    # ACL
    acl_path = 'security/{}.xml'.format(variables['model.name_underscored'])
    if variables['model.acl']:
        _insert_manifest_item(configurator, 'data', acl_path)
    else:
        _delete_file(configurator, acl_path)
    # demo data
    demo_path = 'demo/{}.xml'.format(variables['model.name_underscored'])
    if variables['model.demo_data']:
        _insert_manifest_item(configurator, 'demo', demo_path)
    else:
        _delete_file(configurator, demo_path)
    # show message if any
    show_message(configurator)
Пример #3
0
def post_render_test(configurator):
    # add new test import in __init__.py
    _add_local_import(
        configurator, "tests", configurator.variables["test.name_underscored"]
    )
    # show message if any
    show_message(configurator)
Пример #4
0
def post_render_addon(configurator):
    variables = configurator.variables
    if variables["addon.oca"]:
        _rm_suffix(".oca", configurator, variables["addon.name"] + "/README.rst.oca")
        _rm_suffix(
            ".oca",
            configurator,
            variables["addon.name"] + "/static/description/icon.png.oca",
        )
    else:
        _delete_file(configurator, variables["addon.name"] + "/README.rst.oca")
        _delete_file(
            configurator, variables["addon.name"] + "/static/description/icon.png.oca"
        )
    version = variables["addon.version"]
    if parse_version(version) >= parse_version("10.0"):
        manifest_file = os.path.join(
            configurator.target_directory, variables["addon.name"] + "/__openerp__.py"
        )
        manifest_new_file = os.path.join(
            configurator.target_directory, variables["addon.name"] + "/__manifest__.py"
        )
        os.rename(manifest_file, manifest_new_file)
    # show message if any
    show_message(configurator)
Пример #5
0
def post_render_model(configurator):
    variables = configurator.variables
    # make sure the models package is imported from the addon root
    _add_local_import(configurator, "", "models")
    # add new model import in __init__.py
    _add_local_import(configurator, "models", variables["model.name_underscored"])
    # views
    view_path = "views/{}.xml".format(variables["model.name_underscored"])
    if _model_has_view(variables):
        _insert_manifest_item(configurator, "data", view_path)
    else:
        _delete_file(configurator, view_path)
    # ACL
    acl_path = "security/{}.xml".format(variables["model.name_underscored"])
    if variables["model.acl"]:
        _insert_manifest_item(configurator, "data", acl_path)
    else:
        _delete_file(configurator, acl_path)
    # demo data
    demo_path = "demo/{}.xml".format(variables["model.name_underscored"])
    if variables["model.demo_data"]:
        _insert_manifest_item(configurator, "demo", demo_path)
    else:
        _delete_file(configurator, demo_path)
    # show message if any
    show_message(configurator)
Пример #6
0
def post_render_model(configurator):
    variables = configurator.variables
    # make sure the models package is imported from the addon root
    _add_local_import(configurator, '',
                      'models')
    # add new model import in __init__.py
    _add_local_import(configurator, 'models',
                      variables['model.name_underscored'])
    # views
    view_path = 'views/{}.xml'.format(variables['model.name_underscored'])
    if _model_has_view(variables):
        _insert_manifest_item(configurator, 'data', view_path)
    else:
        _delete_file(configurator, view_path)
    # ACL
    acl_path = 'security/{}.xml'.format(variables['model.name_underscored'])
    if variables['model.acl']:
        _insert_manifest_item(configurator, 'data', acl_path)
    else:
        _delete_file(configurator, acl_path)
    # demo data
    demo_path = 'demo/{}.xml'.format(variables['model.name_underscored'])
    if variables['model.demo_data']:
        _insert_manifest_item(configurator, 'demo', demo_path)
    else:
        _delete_file(configurator, demo_path)
    # show message if any
    show_message(configurator)
Пример #7
0
def post_render_controller(configurator):
    variables = configurator.variables
    # make sure the controllers package is imported from the addon root
    _add_in_file_text(configurator, "", "__init__.py",
                      "from . import controllers")
    # add new model import in __init__.py
    import_string = "from . import {}".format(
        variables["controller.name_underscored"])
    _add_in_file_text(configurator, "controllers", "__init__.py",
                      import_string)
    show_message(configurator)
Пример #8
0
def post_render_wizard(configurator):
    variables = configurator.variables
    # make sure the wizards package is imported from the addon root
    _add_in_file_text(configurator, "", "__init__.py", "from . import wizards")
    # add new model import in __init__.py
    import_string = "from . import {}".format(
        variables["wizard.name_underscored"])
    _add_in_file_text(configurator, "wizards", "__init__.py", import_string)
    # views
    wizard_path = "views/{}.xml".format(variables["wizard.name_underscored"])
    _insert_manifest_item(configurator, "data", wizard_path)
    # show message if any
    show_message(configurator)
Пример #9
0
def post_render_wizard(configurator):
    variables = configurator.variables
    # make sure the wizards package is imported from the addon root
    _add_local_import(configurator, "", "wizards")
    # add new wizard import in __init__.py
    _add_local_import(configurator, "wizards", variables["wizard.name_underscored"])
    # views
    view_path = "wizards/{}.xml".format(variables["wizard.name_underscored"])
    if _wizard_has_view(variables):
        _insert_manifest_item(configurator, "data", view_path)
    else:
        _delete_file(configurator, view_path)
    # show message if any
    show_message(configurator)
Пример #10
0
def post_render_addon(configurator):
    variables = configurator.variables
    if variables['addon.oca']:
        _rm_suffix('.oca', configurator, variables['addon.name'] +
                   '/README.rst.oca')
        _rm_suffix('.oca', configurator, variables['addon.name'] +
                   '/static/description/icon.svg.oca')
    else:
        _delete_file(configurator, variables['addon.name'] +
                     '/README.rst.oca')
        _delete_file(configurator, variables['addon.name'] +
                     '/static/description/icon.svg.oca')
    # show message if any
    show_message(configurator)
Пример #11
0
def post_render_css(configurator):
    variables = configurator.variables
    script_text = """
    <template id="{0}" inherit_id="{1}">
        <xpath expr="." position="inside">
            <link rel="stylesheet" href="/{2}/static/src/css/{0}.css"/>
        </xpath>
    </template>
    """.format(variables["css.name_underscored"], variables["css.inherit"],
               variables["addon.name"])
    _add_in_file_text(configurator, "views", "assets.xml", script_text)
    xml_path = "views/assets.xml".format(variables["view.name_underscored"])
    _insert_manifest_item(configurator, "data", xml_path)
    show_message(configurator)
Пример #12
0
def post_render_js(configurator):
    variables = configurator.variables
    script_text = """
    <template id="{0}" inherit_id="{1}">
        <xpath expr="." position="inside">
            <script type="text/javascript" src="/{2}/static/src/js/{0}.js"></script>
        </xpath>
    </template>
    """.format(variables["js.name_underscored"], variables["js.inherit"],
               variables["addon.name"])
    _add_in_file_text(configurator, "views", "assets.xml", script_text)
    assets_path = "views/assets.xml".format(variables["js.name_underscored"])
    _insert_manifest_item(configurator, "data", assets_path)
    # show message if any
    show_message(configurator)
Пример #13
0
def post_render_wizard(configurator):
    variables = configurator.variables
    # make sure the wizards package is imported from the addon root
    _add_local_import(configurator, '',
                      'wizards')
    # add new wizard import in __init__.py
    _add_local_import(configurator, 'wizards',
                      variables['wizard.name_underscored'])
    # views
    view_path = 'wizards/{}.xml'.format(variables['wizard.name_underscored'])
    if _wizard_has_view(variables):
        _insert_manifest_item(configurator, 'data', view_path)
    else:
        _delete_file(configurator, view_path)
    # show message if any
    show_message(configurator)
Пример #14
0
def post_render_model(configurator):
    variables = configurator.variables
    # make sure the models package is imported from the addon root
    _add_in_file_text(configurator, "", "__init__.py", "from . import models")
    # add new model import in __init__.py
    import_string = "from . import {}".format(
        variables["model.name_underscored"])
    _add_in_file_text(configurator, "models", "__init__.py", import_string)
    security_path = "security/{}_ir.model.access.csv".format(
        variables["model.name_underscored"])
    if not variables["model.security"]:
        _delete_file(configurator, security_path)
    else:
        _insert_manifest_item(configurator, "data", security_path)
    # show message if any
    show_message(configurator)
Пример #15
0
def post_render_model(configurator):
    variables = configurator.variables
    security_path = "security/ir.model.access.csv"
    # make sure the models package is imported from the addon root
    _add_in_file_text(configurator, "", "__init__.py", "from . import models")
    # add new model import in __init__.py
    import_string = "from . import {}".format(
        variables["model.name_underscored"])
    _add_in_file_text(configurator, "models", "__init__.py", import_string)
    if variables["model.security"]:
        import_string = "\naccess_{0},access_{0},model_{0},base.group_user,1,1,1,1".format(
            variables["model.name_underscored"])
        _add_in_file_text(configurator, "security", "ir.model.access.csv",
                          import_string)
        _insert_manifest_item(configurator, "data", security_path)
    # show message if any
    show_message(configurator)
Пример #16
0
def post_render_addon(configurator):
    variables = configurator.variables
    if variables['addon.oca']:
        _rm_suffix('.oca', configurator, variables['addon.name'] +
                   '/README.rst.oca')
        _rm_suffix('.oca', configurator, variables['addon.name'] +
                   '/static/description/icon.png.oca')
    else:
        _delete_file(configurator, variables['addon.name'] +
                     '/README.rst.oca')
        _delete_file(configurator, variables['addon.name'] +
                     '/static/description/icon.png.oca')
    version = variables['addon.version']
    if parse_version(version) >= parse_version('10.0'):
        manifest_file = os.path.join(
            configurator.target_directory,
            variables['addon.name'] + '/__openerp__.py')
        manifest_new_file = os.path.join(
            configurator.target_directory,
            variables['addon.name'] + '/__manifest__.py')
        os.rename(manifest_file, manifest_new_file)
    # show message if any
    show_message(configurator)
Пример #17
0
def post_render_test(configurator):
    variables = configurator.variables
    script_text = """
    <template id="test_{0}" inherit_id="{1}">
        <xpath expr="." position="inside">
            <script type="text/javascript" src="/{2}/static/src/js/test_{0}.js"></script>
        </xpath>
    </template>
    """.format(variables["test.name_underscored"], variables["test.assets"],
               variables["addon.name"])
    _add_in_file_text(configurator, "views", "assets.xml", script_text)
    import_string = "from . import test_{}".format(
        variables["test.name_underscored"])
    _add_in_file_text(configurator, "tests", "__init__.py", import_string)
    assets_path = "views/assets.xml".format(variables["test.name_underscored"])
    js_path = "static/src/js/test_{}.js".format(
        variables["test.name_underscored"])
    if variables["test.tour"]:
        _insert_manifest_item(configurator, "data", assets_path)
    else:
        _delete_file(configurator, js_path)
        _delete_file(configurator, assets_path)
    # show message if any
    show_message(configurator)
Пример #18
0
def post_render_view(configurator):
    variables = configurator.variables
    xml_path = "views/{}.xml".format(variables["view.name_underscored"])
    _insert_manifest_item(configurator, "data", xml_path)
    show_message(configurator)
Пример #19
0
def post_render_qweb(configurator):
    variables = configurator.variables
    qweb_path = "static/src/xml/{}.xml".format(
        variables["qweb.name_underscored"])
    _insert_manifest_item(configurator, "qweb", qweb_path)
    show_message(configurator)
Пример #20
0
def post_render_demo(configurator):
    variables = configurator.variables
    demo_path = "demo/{}.xml".format(variables["demo.name_underscored"])
    _insert_manifest_item(configurator, "demo", demo_path)
    show_message(configurator)
Пример #21
0
def post_render_data(configurator):
    variables = configurator.variables
    data_path = "data/{}.xml".format(variables["data.name_underscored"])
    _insert_manifest_item(configurator, "data", data_path)
    show_message(configurator)
Пример #22
0
def post_render_test(configurator):
    # add new test import in __init__.py
    _add_local_import(configurator, 'tests',
                      configurator.variables['test.name_underscored'])
    # show message if any
    show_message(configurator)