技巧二 Widget使用大全
odoo中有众多原生的widget,覆盖了很多使用场景,可惜的是odoo官方并未整理出一份使用文档. 本章将根据实际使用情况来对常见的诸多widget的使用方法集中介绍一下.
已知的可用Widget列表
- float_time
- many2manyattendee
- many2many_tags
- one2many
- mail_followers
- mail_thread
- many2many_tags_avatar
- pad
- statinfo
- many2many
- radio
- website_redirect_button
- url
- priority
- upgrade_boolean
- activity_exception
- mail_activity
- kanban_activity
- selection
- bullet_state
- embed_viewer
- pdf_viewer
- mrp_time_counter
- handle
- boolean
- label_selection
- CopyClipboardChar
- many2many_tags_email
- hr_org_chart
- res_partner_many2one
- monetary
- float
- phone
- percentpie
- domain
- html
- mass_mailing_html
- many2many_binary
- date
- montary
- image
- boolean_favorite
- many2many_checkboxes
- boolean_toggle
- section_and_note_one2many
- section_and_note_text
- many2one_barcode
- tax-group-custom-field
- payment
- kanban_vat_activity
- dashboard_graph
- account_hierarchy_selection
- state_selection
- website_publish_button
- sms_widget
- link_button
- color
- product_configurator
- progressbar
- daterange
- video_preview
- input
- slide_category_one2many
- field_float_rating
- sale_order_many2one
- gauge
- integer
- selection_badge
- hr_resume
- hr_skills
- website_urls
- matrix_configurator
- section_one2many
- kanban_state_selection
- question_page_one2many
- datetime
- attachment_image
- relative_time
- reference
- timesheet_uom
- toggle_button
- CopyClipboardText
- font
- char
- ace
- timezone_mismatch
- text
- many2one
- field_partner_autocomplete
- iban
- password_meter
- iot_picture
- lot_barcode_handler
- picking_barcode_handler
- barcode_handler
- appointment_employee_url
- twitter_users_autocomplete
- social_post_preview
- signature
- percentage
- Many2one
- deprec_lines_reversed
- json
- back_arrow
- tablet_image
- mrp_pdf_viewer_no_reload
- mrp_embed_viewer_no_reload
- filters
- documents_kanban_color_tags
- timesheet_timer
- color_picker
- hierarchy_kanban
- marketing_activity_graph
- call_center
- social_kanban_field_stream_post
- social_kanban_field_emoji
- social_text_emojis
- contact_sync
- iot_realtime_value
- field_float_scannable
- statusbar
- web_ribbon
statusbar
状态栏statusbar, 这个我们已经十分熟悉了,它的作用就是在form表单上显示一个状态栏位.
<field name="state" widget="statusbar">
其后可以接属性:
- statusbar_visible: 可以显示在statusbar上面的状态值, 以逗号分隔
- clickable: 标识是否可以被点击(仅使用较早版本)
对于13.0+的版本,可以使用options="{'clickable':'1'}"使状态栏可以被点击.
web_ribbon
web_ribbon是13.0开始引入的widget,其作用是在页面右上角添加角标:
使用写法如下:
<widget name="web_ribbon" title="测试角标" />
badge
badge部件可以给Selection的字段设置不同的颜色值:
<field name="delivery_state" widget="badge" decoration-success="delivery_state == 'sent'" decoration-info="delivery_state == 'partial'" decoration-warning="delivery_state == 'no'"/>
- decoration-bf: 粗体
- decoration-it: 斜体
- decoration-danger: 红色
- decoration-info: 蓝色
- decoration-muted: 灰色
- decoration-primary: 深绿色
- decoration-success: 浅绿色
- decoration-warnin: 黄色
domain
ace
ace部件用来显示Python或XML代码。