odoo-8 - 如何在 RML-Odoo v8 中使用“if 条件”
问题描述
我想使用条件根据设置的值打印某些条款和条件。
例如,付款有 10 个“条款和条件”。默认速率为“rate1”,但如果选择“rate2”,则条件 3 和 4 应更改为其他值。
如果设置了“rate1”,则
1. This is condition for both (1 or 2)
2. This is condition for both (1 or 2)
3. This is condition for rate 1
4. This is condition for rate 1
.
.
.
9. This is condition for both (1 or 2)
10. This is condition for both (1 or 2)
如果设置了“rate2”,则
1. This is condition for both (1 or 2)
2. This is condition for both (1 or 2)
3. This is condition for rate 2
4. This is condition for rate 2
.
.
.
9. This is condition for both (1 or 2)
10. This is condition for both (1 or 2)
条款和条件是“静态的”,不存储在对象中。
我的 RML 是这样的:
<tr>
<td><para>1</para></td>
<td><para>This is condition for both (1 or 2)</para></td>
</tr>
<tr>
<td><para>2</para></td>
<td><para>This is condition for both (1 or 2)</para></td>
</tr>
<tr>
<td><para>3</para></td>
<td><para>This is condition for rate 1</para></td>
</tr>
有什么方法可以在第 3 行使用“条件”。
先感谢您。
解决方案
我不确定它在 RML 中是否完全具有“if else 条件”。
但就我而言,我设法解决了以下问题,并且可能对像我这样的人有所帮助。
[[ r.rate2 != '']]
[['3. Condition for Rate 2 '']]
[[ r.rate1 != '']]
[['3. Condition for Rate 1 '']]
或者
[[(r.rate1 == 0 and ' ') or '3. Condition for Rate 1']]
[[(r.rate2 == 0 and ' ') or '3. Condition for Rate 2']]
这似乎不是一个好方法,但解决了问题。
如果找到更好的方法,将永远不胜感激。
推荐阅读
- python - 如何将用户输入添加到空的 numpy 数组
- r - 将多个栅格图写入 .png
- javascript - 从文件输入中删除文件(Materialize-css)
- python - 计算滚动时间窗口的百分比变化
- python - 如何从 csv 标题行获取周数和星期几,然后附加值
- python - 无法在 jupyter notebook 中安装模块
- c# - 使用从 C# DLL 获取 PS 脚本名称?获取“对象引用未设置为对象的实例。”
- nearprotocol - 如何测试 NEAR 是否被转移?
- reactjs - 我可以通过组件列表进行映射吗?
- c# - WPF DataGrid:使用 GongSolutions.WPF.DragDrop 重新排序和编辑行