Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5033 Lượt xem

Hello everyone!

I'm about to using Odoo (v10) to run several webshops and websites. To share the frontend style (css) I've managed the structure into several modules to inherit style definitions from less-files. The structure looks as followed:

default_theme/static/private/less/header.less
default_theme/static/private/less/default.less (includes header.less, variables and so on)

default_shop/static/private/less/header.less
default_shop/static/private/less/default.less (imports default.less from default_theme + header.less of this module)

shop_A/static/private/less/header.less
shop_A/static/private/less/theme.less (imports default.less from the default_shop + header.less of this module and several additional variables and specifications for the shop)

The only less file that will be included via assets XML will be the one from the shop_A module. That is my setup / idea.

When I run the system I get the following error:

Local import '../../default_theme/static/private/less/default.less' is forbidden for security reasons.

When I dive into the source code I've seen that as soon as there are any "." in the import paths the script will fail.
How can I manage my less files into separate files instead of writing one large less file? Furthermore I want to split the style logic into several reusable modules instead of one module.

Hope that maybe someone can help me out.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can easily create reusable theme modules. Please make sure, that you have defined the corresponding dependencies in the __manifest__.py file. You can add new assets to the already defined assets of the depending modules by inheriting the assets file and adding new links, such as:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="less" name="tw yings design" inherit_id="website.assets_frontend" active="True" priority="1">
<xpath expr="link[last()]" position="after">
<link href="/tw_yings_design/static/src/less/typography.less" rel="stylesheet" type="text/less"/>
<link href="/tw_yings_design/static/src/less/misc_classes.less" rel="stylesheet" type="text/less"/>
<link href="/tw_yings_design/static/src/less/options/colors/colorPreset1.less" rel="stylesheet" type="text/less"/>
</xpath>
</template>
</odoo>


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Ermin, thanks that worked - altough it looks better to have those inheritances and imports directly in less. ;)

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 18
3816
1
thg 1 17
7951
0
thg 11 16
3185
1
thg 6 24
40242
8
thg 12 23
17493