odoo自定义css

1.在__manifest__.py加入css文件路径

'css': ['static/src/css/ab.css'],

2.定义css文件

.ted
{
    background-color: #fff;
    font-size: 36px;
}
.fss
{
    color:red !important;
}

3.定义测试字段

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _

class ZfyStockPicking(models.Model):
    _inherit = 'stock.picking'

    abc = fields.Char(u'测试字段颜色')

4.在xml文件中引入css文件,及新增测试字段用以测试

<template id="assets_backend" inherit_id="web.assets_backend" name="zfy_assets_backend">
        <xpath expr="." position="inside">
            <link rel="stylesheet" type="text/css" href="/css_test/static/src/css/ab.css"/>
        </xpath>
    </template>
    <record id="view_stock_picking_form_inherit" model="ir.ui.view">
        <field name="name">view_stock_picking_form_inherit</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form"/>
        <field name="arch" type="xml">
            <field name="partner_id" position="after">
                <field name="abc" class="fss"/>
            </field>
        </field>
    </record>

效果如图:

如果在pdf中,也可以直接定义在template中定义css,然后引用

<template id="stock_picking_report1">
        <style type="text/css">
            .ssgt
            {
                color: red;
            }
            table.pptg
            {
                color: blue;
            }
        </style>
        <t t-call="report.html_container">
            <div class="page ssgt">
                <div class="row">
                    <div class="col-xs-4">
                        <strong>单据号:</strong>
                        <p t-esc="docs.name"/>
                    </div>
                </div>
                <table class="table pptg">
                    <thead>
                        <tr>
                            <th>行号</th>
                            <th>产品名称</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr style="page-break-inside : avoid"
                            t-foreach="docs.move_lines" t-as="lot">
                            <td>
                                <span t-esc="lot.product_id.display_name"/>
                            </td>
                            <td>
                                <span t-esc="lot.product_uom_qty"/>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </t>
    </template>

效果如图:

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值