如何使用fields.function?

2024-04-19 06:43:26 发布

您现在位置:Python中文网/ 问答频道 /正文

你能帮助我了解字段.函数通过这个密码?在

'progress': fields.function(_hours_get, string='Working Time Progress (%)', multi='hours', group_operator="avg", help="If the task has a progress of 99.99% you should close the task if it's finished or reevaluate the time",
                store = {
                    'project.task': (lambda self, cr, uid, ids, c={}: ids, ['work_ids', 'remaining_hours', 'planned_hours', 'state', 'stage_id'], 10),
                    'project.task.work': (_get_task, ['hours'], 10),
                }),

我需要了解他们。 希望得到回应。 谢谢并致以诚挚的问候


Tags: the函数projectids密码fieldstaskget
1条回答
网友
1楼 · 发布于 2024-04-19 06:43:26

我给你举个简单的例子来理解字段.函数. 在

示例:

    def _check_bool(self, cr, uid, ids, field_name, arg, context):
       res={}
       for req in self.browse(cr, uid, ids, context=context):
          if req.bool:
                res[req.id] = True
          else:
                res[req.id] = False
       return res

    _columns = {
       'bool' : fields.boolean(),
       'check_bool': fields.function(_check_bool, type="boolean", obj="generic.request", method=True),
    }

\u check_bool函数检查字段“bool”是否为真或假,并对字段“check_bool”执行相同的操作。如果您有问题,我在此为您提供帮助。在

相关问题 更多 >