odoo模板中例子

odoo版本:8

一、小图标

<div class="oe_kanban_footer_left">
    <span title='Messages'><span class='oe_e'>9</span><t t-esc="record.message_ids.raw_value.length"/></span>
    <span title='Followers'><span class='oe_e'>+</span><t t-esc="record.message_follower_ids.raw_value.length"/></span>
</div>

代码位置:openerp/addons/hr/hr_view.xml 170行

效果图:


主要是<span class='oe_e'>9</span>这行代码“9”代表消息的图标,“+”代表联系人的图标,字符和图标的对应有个列表的http://www.fontslog.com/entypo-regular-otf-33800.htm

二、组合按钮

<div class="oe_right oe_button_box" name="buttons">
    <button class="oe_inline oe_stat_button" type="action"
        context="{'default_opportunity_id': active_id, 'search_default_opportunity_id': active_id, 'default_partner_id': partner_id, 'default_duration': 1.0}"
        name="%(crm.crm_case_categ_phone_incoming0)d" icon="fa-phone">
        <div>Schedule/Log<br/>Calls</div>
    </button>
</div>

代码位置:openerp/addons/crm/crm_lead_view.xml

效果图:


这个按钮绑定了crm_case_categ_phone_incoming0动作,按钮中显示的图标可在下列连接中找

https://avada.theme-fusion.com/font-awesome-icons/

三、阶段条

                <header>
                    <button name="%(crm.action_crm_lead2opportunity_partner)d" string="Convert to Opportunity" type="action"
                            help="Convert to Opportunity" class="oe_highlight"/>
                    <field name="stage_id" widget="statusbar" clickable="True"
                            domain="['&', '|', ('case_default', '=', True), ('section_ids', '=', section_id), '|', ('type', '=', type), ('type', '=', 'both')]"
                            options="{'fold_field': 'fold'}"
                            on_change="onchange_stage_id(stage_id)"/>
                </header>

代码位置openerp/addons/crm/crm_lead_view.xml 94行

视图中插入这段,会显示当前的阶段,使用控件statusbar,domain是筛选条件;option指定字段窗口小部件的配置,这里是叠加;on_change是在编辑此字段时调用对应的方法,可以为用户生成或更新其他字段或显示警告;

效果图:


附上控件其他类型:


四、评级小星星

效果图:


字段的定义:

AVAILABLE_PRIORITIES = [
    ('0', 'Very Low'),
    ('1', 'Low'),
    ('2', 'Normal'),
    ('3', 'High'),
    ('4', 'Very High'),
]
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True),

在视图中:

<field name="priority" widget="priority"/>

可设置该字段的默认值,在_defaults中添加代码:

'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
这样默认的情况下是两颗星,Normal。


五、文字按钮

效果图:


后面的是按钮,连接的是一个action响应,好奇那个箭头是怎么来的,结果...

<group string="Stock and Expected Variations" attrs="{'invisible': [('type', '=', 'service')]}" groups="base.group_user">
    <label for="qty_available"/>
        <div>
            <field name="qty_available" class="oe_inline"/>
            <button name="%(action_view_change_product_quantity)d" string="⇒ Update"
                type="action"
                class="oe_link"/>
        </div>
    <label for="incoming_qty"/>
        <div>
            <field name="incoming_qty" class="oe_inline"/>
            <button string="⇒ Request Procurement" name="%(stock.act_make_procurement)d" type="action" class="oe_link"/>
        </div>
    <field name="virtual_available"/>
</group>

emmmmmmm就是直接打上去的。

六、菜单上的提示数字

展示图:


左侧菜单栏中的消息提示,首先模块要继承ir.needaction_mixin

_inherit = ['ir.needaction_mixin']

然后在模块内重写_needaction_domain_get函数

#=================================================================
#@name:_needaction_domain_get
#@description:Addedforbadgenumberinmenu
@api.model
def_needaction_domain_get(self):
return[('leave_apply_id.state','in',['applied','approved_by_mgr'])]

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值