You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

QWeb报表中如何仅移除<tfoot>元素的边框?

解答:是的,需要自定义CSS来实现这个需求

默认的table-bordered类(Odoo自带的Bootstrap风格类)会给表格里所有<td>、<th>元素(包括<tfoot>内的)统一添加边框样式,所以要单独移除<tfoot>的边框,必须通过自定义CSS来覆盖默认规则。

下面是两种实用的实现方案:

方案一:精准定位目标表格的tfoot

直接在你的QWeb报表模板中添加自定义CSS,通过表格的name属性精准锁定目标,避免影响其他报表的表格:

<style>
/* 仅针对name为moves_table的表格,移除tfoot的边框 */
table[name="moves_table"].table-bordered tfoot td,
table[name="moves_table"].table-bordered tfoot th {
    border: none !important;
}
</style>

这里的!important是为了确保样式优先级高于Bootstrap的默认边框规则,保证修改生效。

方案二:给tfoot添加自定义类,提升复用性

如果后续其他表格也需要类似效果,可以给<tfoot>加一个专属类,再写对应样式:
首先修改<tfoot>标签:

<tfoot class="no-border-tfoot">
  <!-- 你的tfoot内容 -->
</tfoot>

然后添加CSS规则:

<style>
.table-bordered .no-border-tfoot td,
.table-bordered .no-border-tfoot th {
    border: none !important;
}
</style>

这种方式可以把no-border-tfoot类复用在任意需要移除tfoot边框的表格上。

修改后的完整代码示例(方案二)

<style>
.table-bordered .no-border-tfoot td,
.table-bordered .no-border-tfoot th {
    border: none !important;
}
</style>

<table style="border-color:grey;" class="table-bordered table-sm o_main_table" name="moves_table"> 
  <thead> 
    <tr> 
      <th>No</th> 
      <th>Description</th> 
      <th class="text-center">Code</th> 
      <th class="text-right">Units</th> 
      <th class="text-right">Quantity</th> 
      <th class="text-right">Package quantity</th> 
      <th class="text-right">Net weight (kg)</th> 
      <th class="text-right">Weight incl. packaging</th> 
      <th class="text-right">Type of package</th> 
    </tr> 
  </thead> 
  <tbody class="invoice_tbody"> 
    <tr t-foreach="o.move_ids_without_package" t-as="l"> 
      <td class="text-center"> 
        <span t-esc="l_index + 1" /> 
      </td> 
      <td> 
        <span t-field="l.name"/> 
      </td> 
      <td> 
        <span t-field="l.product_id.default_code"/> 
      </td> 
      <td class="text-right"> 
        <span t-field="l.product_uom.name"/> 
      </td> 
      <td class="text-right"> 
        <span t-esc="'%.2f'%(l.product_uom_qty)"/> 
      </td> 
      <td class="text-right"> 
        <span t-esc="'%.2f'%(l.product_uom_qty)"/> 
      </td> 
      <td class="text-right"> 
        <span t-esc="'%.2f'%(l.product_uom_qty)"/> 
      </td> 
      <td class="text-right"> 
        <span t-esc="'%.2f'%(l.product_uom_qty)"/> 
      </td> 
      <td class="text-right"> 
        <span t-esc="'%.2f'%(l.product_uom_qty)"/> 
      </td> 
    </tr> 
  </tbody> 
  <tfoot class="no-border-tfoot"> 
    <tr> 
      <td></td> 
      <td></td> 
      <td></td> 
      <td class="text-right"><span><strong>Total amount</strong></span></td> 
      <td class="text-right"><span t-esc="sum(o.move_ids_without_package.mapped('product_uom_qty'))"/></td> 
      <td class="text-right"><span t-esc="sum(o.move_ids_without_package.mapped('product_uom_qty'))"/></td> 
      <td class="text-right"><span t-esc="sum(o.move_ids_without_package.mapped('product_uom_qty'))"/></td> 
      <td class="text-right"><span t-esc="sum(o.move_ids_without_package.mapped('product_uom_qty'))"/></td> 
    </tr> 
    <tr> 
      <td></td> 
      <td></td> 
      <td></td> 
      <td class="text-right"><span><strong>Total Weight</strong></span></td> 
      <td></td> 
      <td></td> 
      <td></td> 
      <td class="text-right"><span t-esc="sum(o.move_ids_without_package.mapped('product_uom_qty'))"/></td> 
    </tr> 
  </tfoot> 
</table>

这样设置后,<thead>和<tbody>的边框会完全保留,只有<tfoot>的单元格边框会被移除,完全符合你的需求。

内容的提问来源于stack exchange,提问作者Chaban33

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:16:08