[英]How to using fields.function?
你能通過這段代碼幫助我理解Field.function的功能和工作嗎?
'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),
}),
我需要了解他們。 希望得到回應。 謝謝和最好的問候
我會給你一個簡單的例子來理解 Field.function。
例子:
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),
}
_check_bool函數檢查字段“bool”是否為 True 或 False,並為字段“check_bool”設置相同代碼很容易理解,如果您有問題我可以在這里幫助您。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.