action类型的按钮和object按钮的用法

<div class="oe_right oe_button_box" name="buttons">
<button class="oe_inline oe_stat_button" icon="fa-flask" name="action_view_sale_order" type="object">
<field string="相关单据" name="sale_counts" widget="statinfo" />
</button>
class是固定格式,icon是样式,name表示动作按钮,type表示类型
string表示按钮在标签上显示名字,name="sale_counts"表示记录单据条数,是一个方法

<button class="oe_inline oe_stat_button" icon="fa-truck" name="action_view_wave_picking" type="object">
<field string="发货单" name="delivery_count" widget="statinfo" />


</button>
</div>

# 新加地方,要记录对账单条数,该客户
def _get_partner_account_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, 0)
try:
name=self.browse(cr,uid,ids[0],context=context).name
obj=self.pool('partner.account.state')
sale_ids=obj.search(cr,uid,[('partner_id','=',ids)])
res[ids[0]]=len(sale_ids)
except:
print u"err"
finally:
return res
# 新加地方,执行动作找到对应页面
# 新加地方,执行动作找到对应页面
def action_partner_account_state1(self, cr, uid, ids, context=None):

name指的是客户名字
name=self.browse(cr,uid,ids[0],context=context).name
act_obj = self.pool.get('ir.actions.act_window')
mod_obj = self.pool.get('ir.model.data')
result = mod_obj.xmlid_to_res_id(cr, uid, 'ks_sale.action_partner_account_state',raise_if_not_found=True)
result = act_obj.read(cr, uid, [result], context=context)[0]

过滤条件1
result['domain'] = "[('partner_id','=','"+ name +"')]"
 过滤条件2
result['domain'] = "[('origin','=',"+ str(ids[0]) +")]"
这两种都可以,优先指的是过滤条件为2的为标准
return result
 
 



<xpath expr="//div[@name='buttons']" position="inside">
<button class="oe_inline oe_stat_button" type="action" name="%(sale.act_res_partner_2_sale_order)d"
attrs="{'invisible': [('customer', '=', False)]}"
icon="fa-strikethrough">
<field string="Sales" name="sale_order_count" widget="statinfo"/>
</button>
</xpath>



跟上面差不多:

 

 
 






至于两个按钮区别还没有研究过

转载于:https://www.cnblogs.com/1314520xh/p/6891433.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值