###################################################################################
#odoo中常用方法,在动作里面添加按钮:执行批量操作
###################################################################################
import re
import json
import logging
from lxml import etree
from odoo import api, fields, models
_logger = logging.getLogger(__name__)
class ResUser(models.Model):
_inherit = 'res.users'
@api.multi
def batch\_select\_action(self):
for order in self:
"""编写你想要实现的功能代码"""
pass
#action对应的xml情况
#在动作里添加下拉的向导:情况2:直接执行函数---002
<record id="model\_res\_users\_submit\_action\_server" model="ir.actions.server">
<field name="name">Submit To Manager</field>
<field name="type">ir.actions.server</field>
<field name="model\_id" ref="model\_res\_users"/>
<field name="state">code</field>
<field name="code">
if records:
action = records.batch_select_action()
<record id="action\_res\_users\_submit" model="ir.values">
<field name="name">Submit To Manager</field>
<field name="model\_id" ref="model\_res\_users"/>
<field name="model">res.users</field>
<field name="key2">client\_action\_multi</field>
<field eval="'ir.actions.server,%d'%model\_res\_users\_submit\_action\_server" name="value"/>
</record>
#在xml里编写的动作:
情况00001---odoo12、odoo10均可用
"""
在动作里添加下拉的向导:情况1、弹出向导,在向导里添加动作
"""
# odoo10中可用,odoo12中待验证
#情况00002
#在动作里添加下拉的向导:情况2:直接执行函数
<record id="action\_assign\_salesman\_according\_assigned\_partner" model="ir.actions.server">
<field name="name">Assign salesman</field>
<field name="model\_id" ref="model\_crm\_lead"/>
<field name="state">code</field>
<field name="code">
if env.context.get('active\_domain'):
records = model.search(env.context\['active\_domain'\])
records.assign\_salesman\_of\_assigned\_partner()
</field>
</record>
<record model="ir.values" id="ir\_assign\_salesman\_according\_assigned\_partner">
<field name="model\_id" ref="model\_crm\_lead" />
<field name="name">Assign salesman of assigned partner</field>
<field name="key2">client\_action\_multi</field>
<field eval="'ir.actions.server,%d'%action\_assign\_salesman\_according\_assigned\_partner" name="value"/>
<field name="key">action</field>
<field name="model">crm.lead</field>
</record>
手机扫一扫
移动阅读更方便
你可能感兴趣的文章