Odoo View 常用技巧
2024-10-20 21:03:21
隐藏Field
<field name="currency_id" invisible="True"/>
<field name="currency_id" invisible="1"/>
在某种条件下隐藏
<field name="expense_description" attrs="{'invisible':[('expense_audit','!=','1')]}" />
隐藏label
<field name="description" widget="html" nolabel="True"/>
<field name="description" widget="html" nolabel="1"/>
只读 readonly
<field name="budget_id" readonly="True"/>
条件 domain
<field name="product_id" domain="[('pro_type','=','rests')]"/>
设定值 eval
<field name="fill_date" eval="datetime.now()" readonly="True"/>
表单传值 context (以 default_
开始代表直接赋值过去)
<button class="oe_stat_button" name="%(budget_review_action)d" type="action" icon="fa-calendar-check-o" attrs="{'invisible':[('state','!=','check')]}" context="{'default_budget_id': id, 'default_contract_area': square, 'default_contract_price': total_price, 'default_start_date': start_date, 'default_end_date': end_date}" string="创建审核单"/>a
Widget
many2one widget (default)
- no_quick_create - remove the Create and edit... option.
- no_create_edit - remove the Create "search_value" option.
- no_create - no_quick_create and no_create_edit combined.
- no_open - in read mode: do not render as a link.
<field name="field_name" options="{'no_quick_create': True, 'no_create_edit' : True}"/>
many2many widget (default)
- no_create - remove the Create button.
<field name="field_name" options="{'no_create': True}"/>
many2many_tags widget
- no_quick_create - remove the Create and edit... option.
- no_create_edit - remove the Create "search_value" option.
- no_create - no_quick_create and no_create_edit together.
<field name="field_name" widget="many2many_tags" options="{'no_create_edit': True}"/>
one2many tree
- create - remove the Create button.
- edit - remove the Edit button.
- delete - remove the Delete button.
<field name="basic_incidentals" mode="tree" nolabel="1">
<tree create="false" edit="false" delete="false">
<field name="name"/>
<field name="model"/>
<field name="specifications"/>
<field name="price" invisible="True"/>
<field name="number" invisible="True"/>
<field name="unit" invisible="True"/>
<field name="total_price" invisible="True"/>
<field name="remarks" invisible="True"/>
</tree>
</field>
Fields
生成一个动态的Selection,比如当前时间的前后5年!
import datetime
year = fields.Selection(string=u'年度', selection=[(num, str(num)) for num in range((datetime.datetime.now().year - 5), (datetime.datetime.now().year + 5))])
最新文章
- 基于Caffe的DeepID2实现(中)
- Maven+Spring+Spring MVC+MyBatis+MySQL,搭建SSM框架环境【转】
- CGGeometry.h 文件详解
- thinkphp修改及编写标签库,编辑器的使用
- div的一些易出错地方
- linux设备驱动归纳总结(八):1.总线、设备和驱动【转】
- 树-伸展树(Splay Tree)
- 用Android++在Visual Studio中用C/C++开发Android应用
- gooflow0.6的流程设计
- doT.js实例详解
- DelayQueue的原理和使用浅谈
- EntityFramework Core进行读写分离最佳实践方式,了解一下(一)?
- stringstream
- stm8 iar开发
- STM32应用实例五:与SHT1X温湿度传感器通讯
- virt-install vs qemu-kvm创建guest主机
- Django model转字典的几种方法
- tomcat catalina.out日志切割(logrotate)
- Python2.7-shutil
- C# 验证过滤代理IP是否有效