本文整理汇总了Python中trytond.pool.Pool.get_triggers方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.get_triggers方法的具体用法?Python Pool.get_triggers怎么用?Python Pool.get_triggers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.get_triggers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trigger_create
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_triggers [as 别名]
def trigger_create(self, id):
'''
Trigger create actions
:param id: the created id
'''
trigger_obj = Pool().get('ir.trigger')
trigger_ids = trigger_obj.get_triggers(self._name, 'create')
if not trigger_ids:
return
record = self.browse(id)
triggers = trigger_obj.browse(trigger_ids)
for trigger in triggers:
if trigger_obj.eval(trigger, record):
trigger_obj.trigger_action([id], trigger.id)
示例2: trigger_delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_triggers [as 别名]
def trigger_delete(self, ids):
'''
Trigger delete actions
:param ids: the deleted ids
'''
trigger_obj = Pool().get('ir.trigger')
trigger_ids = trigger_obj.get_triggers(self._name, 'delete')
if not trigger_ids:
return
records = self.browse(ids)
triggers = trigger_obj.browse(trigger_ids)
for trigger in triggers:
triggered_ids = []
for record in records:
if trigger_obj.eval(trigger, record):
triggered_ids.append(record.id)
if triggered_ids:
trigger_obj.trigger_action(triggered_ids, trigger.id)
示例3: trigger_write_get_eligibles
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import get_triggers [as 别名]
def trigger_write_get_eligibles(self, ids):
'''
Return eligible ids for write actions by triggers
:param ids: a list of ids
:return: a dictionary of the lists of eligible ids by triggers
'''
trigger_obj = Pool().get('ir.trigger')
trigger_ids = trigger_obj.get_triggers(self._name, 'write')
if not trigger_ids:
return {}
records = self.browse(ids)
triggers = trigger_obj.browse(trigger_ids)
eligibles = {}
for trigger in triggers:
eligibles[trigger.id] = []
for record in records:
if not trigger_obj.eval(trigger, record):
eligibles[trigger.id].append(record.id)
return eligibles