Openerp function fields

前端 未结 3 828
太阳男子
太阳男子 2021-01-16 02:21

Hey I\'m new to openerp and I need help to create a function field called Total that calculates the sum of all the fields of the same object... eg.

_name = \         


        
相关标签:
3条回答
  • 2021-01-16 03:08
    def get_total(self, cr, uid, ids, field_name, arg, context):
        res = []
        perfos = self.browse(cr, uid, ids, context)
        for perfo in perfos:
            res[perfo.id] = perfo.p + perfo.b
    
        return res
    
    0 讨论(0)
  • 2021-01-16 03:08
    def get_total(self, cr, uid, field_name, arg, context):
        for obj in self.browse(cr, uid, ids, context=context):
            return obj.p + obj.b
    

    One can directly use browse method and access list of data attached with that record.

    0 讨论(0)
  • 2021-01-16 03:10

    Start here : Documentation of fields

    0 讨论(0)
提交回复
热议问题