Odoo16 实用功能之在Form视图的各个部位加入按钮

 

目录

1、 如何在form视图中的头部加上按钮

2、如何在form视图中的身体加上按钮

3、如何在notebook标签中加入按钮

 

 


 

1、 如何在form视图中的头部加上按钮

以CRM中的渠道form视图为例子介绍(实现红框中的效果)

 

 直接在<header>标签里加入按钮即可

<header>
    <button name="action_set_won_rainbowman" string="Won"
            type="object" class="oe_highlight" data-hotkey="w" title="Mark as won"
            attrs="{'invisible': ['|','|', ('active','=',False), ('probability', '=', 100), ('type', '=', 'lead')]}"/>
    <button name="%(crm.crm_lead_lost_action)d" string="Lost" data-hotkey="l" title="Mark as lost"
            type="action" context="{'default_lead_id': active_id}"
            attrs="{'invisible': ['|', ('type', '=', 'lead'), '&amp;',('active', '=', False),('probability', '&lt;', 100)]}"/>
    <button name="%(crm.action_crm_lead2opportunity_partner)d" string="Convert to Opportunity" type="action"
            help="Convert to Opportunity"
            class="oe_highlight" attrs="{'invisible': ['|', ('type', '=', 'opportunity'), ('active', '=', False)]}"
            data-hotkey="v"/>
    <button name="toggle_active" string="Restore" type="object" data-hotkey="z"
            attrs="{'invisible': ['|', ('probability', '&gt;', 0), ('active', '=', True)]}"/>
    <button name="action_set_lost" string="Lost" type="object" data-hotkey="l" title="Mark as lost"
            attrs="{'invisible': ['|', ('type', '=', 'opportunity'), '&amp;', ('probability', '=', 0), ('active', '=', False)]}"/>
    <field name="stage_id" widget="statusbar" class="o_field_statusbar"
           options="{'clickable': '1', 'fold_field': 'fold'}"
           domain="['|', ('team_id', '=', team_id), ('team_id', '=', False)]"
           attrs="{'invisible': ['|', ('active', '=', False), ('type', '=', 'lead')]}"/>
</header>

2、如何在form视图中的身体加上按钮

 

 直接在<sheet>标签中加入(需要创建一个可以存放button的盒子button_box)

<div class="oe_button_box" name="button_box">
    <button name="action_schedule_meeting" type="object"
            class="oe_stat_button" icon="fa-calendar"
            context="{'partner_id': partner_id}"
            attrs="{'invisible': [('type', '=', 'lead')]}">
        <div class="o_stat_info">
            <field name="calendar_event_count" class="o_stat_value"/>
            <span class="o_stat_text" attrs="{'invisible': [('calendar_event_count', '&lt;', 2)]}"> Meetings</span>
            <span class="o_stat_text" attrs="{'invisible': [('calendar_event_count', '&gt;', 1)]}"> Meeting</span>
        </div>
    </button>
    <button name="action_show_potential_duplicates" type="object"
            class="oe_stat_button" icon="fa-star"
            attrs="{'invisible': [('duplicate_lead_count', '&lt;', 1)]}">
        <div class="o_stat_info">
            <field name="duplicate_lead_count" class="o_stat_value"/>
            <span class="o_stat_text" attrs="{'invisible': [('duplicate_lead_count', '&lt;', 2)]}">Similar Leads</span>
            <span class="o_stat_text" attrs="{'invisible': [('duplicate_lead_count', '&gt;', 1)]}">Similar Lead</span>
        </div>
    </button>
</div>

3、如何在notebook标签中加入按钮

 直接在<notebook>标签加入按钮即可(需要先创建一个page页面)

<notebook>
    <page string='Power Shell' name='page_powershell'>
        <field name='description' placeholder='请在这里输入命令~'/>
        <button string="执行脚本" type="object" name="save" class="oe_highlight" data-hotkey="insert"/>
    </page>
</notebook>

  • 14
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dear.爬虫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值