odoo - 在销售订单总成本中添加表格行
odoo - add tablerow in sales order total costs
我想在销售订单中的总未税成本和总税费之间添加一行。查看 report_saleorder.xml
我的行时应在以下代码中添加:
<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="o.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="o.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</div>
由于编辑核心 xml 不是一个选项,我想知道是否可以使用 <xpath>
来做到这一点,但我不确定如何去做。我已经在我的 sale.py 文件中创建了一个 field
并查看他们的代码,我的 xml 应该类似于
<tr>
<td>Insurance</td>
<td class="text-right">
<span t-field="o.amount_insurance" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
任何有关我如何能够做到这一点的帮助将不胜感激
是的,你是绝对正确的修改现有代码不是一个好主意,因为当你更新模块时你会丢失更改,所以正确的方法不是继承视图,在这种情况下你需要继承视图模板report_saleorder_document
并使用 xpath 标记将所需字段添加为所需字段:
如果您在界面本身中执行操作,请使用以下语法创建一个新的视图记录并从 report_saleorder_document
.
继承它
<?xml version="1.0"?>
<data inherit_id="sale.report_saleorder_document">
<xpath expr="//div[@class='col-xs-4 pull-right']/table/tr[2]" position="after">
<tr>
<td>Insurance</td>
<td class="text-right">
<span t-field="o.amount_insurance" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
</xpath>
</data>
如果您是通过代码进行操作,则添加继承的视图定义。它应该看起来像这样:
要通过代码进行更改,请创建新文件并添加以下代码:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_saleorder_insurance_inherit" inherit_id="sale.report_saleorder_document">
<xpath expr="//div[@class='col-xs-4 pull-right']/table/tr[2]" position="after">
<tr>
<td>Insurance</td>
<td class="text-right">
<span t-field="o.amount_insurance" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
</xpath>
</template>
</data>
</openerp>
别忘了在清单下注册我们的文件
最佳
我想在销售订单中的总未税成本和总税费之间添加一行。查看 report_saleorder.xml
我的行时应在以下代码中添加:
<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="o.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="o.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</div>
由于编辑核心 xml 不是一个选项,我想知道是否可以使用 <xpath>
来做到这一点,但我不确定如何去做。我已经在我的 sale.py 文件中创建了一个 field
并查看他们的代码,我的 xml 应该类似于
<tr>
<td>Insurance</td>
<td class="text-right">
<span t-field="o.amount_insurance" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
任何有关我如何能够做到这一点的帮助将不胜感激
是的,你是绝对正确的修改现有代码不是一个好主意,因为当你更新模块时你会丢失更改,所以正确的方法不是继承视图,在这种情况下你需要继承视图模板report_saleorder_document
并使用 xpath 标记将所需字段添加为所需字段:
如果您在界面本身中执行操作,请使用以下语法创建一个新的视图记录并从 report_saleorder_document
.
<?xml version="1.0"?>
<data inherit_id="sale.report_saleorder_document">
<xpath expr="//div[@class='col-xs-4 pull-right']/table/tr[2]" position="after">
<tr>
<td>Insurance</td>
<td class="text-right">
<span t-field="o.amount_insurance" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
</xpath>
</data>
如果您是通过代码进行操作,则添加继承的视图定义。它应该看起来像这样:
要通过代码进行更改,请创建新文件并添加以下代码:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_saleorder_insurance_inherit" inherit_id="sale.report_saleorder_document">
<xpath expr="//div[@class='col-xs-4 pull-right']/table/tr[2]" position="after">
<tr>
<td>Insurance</td>
<td class="text-right">
<span t-field="o.amount_insurance" t-field-options='{"widget": "monetary", "display_currency": "o.pricelist_id.currency_id"}'/>
</td>
</tr>
</xpath>
</template>
</data>
</openerp>
别忘了在清单下注册我们的文件
最佳