序言:時間是我們最寶貴的財富,珍惜手上的每個時分
????????從最初的tinyERP到Open ERP,再由OpenERP到Odoo,雖然UI已經過了多次大改,Odoo登錄界面依舊丑陋,同時還有各種Odoo版權信息,對于定制項目而言是不友好的。
????????今天以Odoo18為例,我們來做一個簡單的即插即用的修改。
話不多說,直接上代碼
新建文件:views/login_template.xml:
<?xml version="1.0" encoding="utf-8"?>
<odoo><template id="login_layout" inherit_id="web.login_layout" name="web Login Inherit"><xpath expr="//*[@class='text-center small mt-4 pt-3 border-top']"position="attributes"><attribute name="style">display:none</attribute></xpath><xpath expr="//*[@t-attf-class='card border-0 mx-auto bg-100 {{login_card_classes}} o_database_list']"position="attributes"><attribute name="style">max-width: 500px;margin-top:4rem; opacity: 0.8;</attribute></xpath></template><template id="ro_login"><t t-call="web.login_layout"><style>#wrapwrap{<!-- background-color:#1c7bd4 !important;-->background-image:url(/模塊名稱/static/src/login.png);"}</style><form t-attf-class="oe_login_form" role="form" t-attf-action="/web/login"method="post" onsubmit="this.action = '/web/login' + location.hash"><input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/><div class="mb-3 field-login"><label for="login" class="form-label d-flex justify-content-between">用戶名</label><input type="text" placeholder="用戶名" name="login" t-att-value="login" id="login"class="form-control" required="required" autocapitalize="off" autocomplete="username"/></div><div class="mb-3"><label for="password" class="form-label d-flex justify-content-between">密碼</label><input type="password" placeholder="密碼" name="password" id="password" class="form-control"required="required" autocomplete="current-password"t-att-autofocus="'autofocus' if login else None" maxlength="4096"/></div><p class="alert alert-danger" t-if="error" role="alert"><t t-esc="error"/></p><p class="alert alert-success" t-if="message" role="status"><t t-esc="message"/></p><div class="oe_login_buttons text-center gap-1 d-grid mb-1 pt-3"><button type="submit" class="btn btn-primary">登錄</button></div></form></t></template></odoo>
引入視圖:__manifiest__.py
''''data': ['views/login_template.xml',],
'''
新建 static/src文件夾,放入 login.png,此為背景圖片,自己選素材即可。
在模塊中做如上幾步,即大功告成。