关于OpenERP的简单数学

时间:2015-07-31 07:39:46

标签: python openerp odoo

如何创建将在报告中显示的示例2 + 2的附加内容?我试过用:

num1:fields.integer('Number1', digits=16,2)),
num2:fields.float('Number2', digits=(16,2)),
result:fields.function(addition(char1,char2)),

1 个答案:

答案 0 :(得分:0)

  def _addition(self, cr, uid, ids, fields, arg, context):
      r = {}
      for record in self.browse(cr, uid, ids):
          r[record.id] = record.num1 + record.num2
      return r

  'num1' : fields.integer('Num1'),
  'num2' : fields.float('Num2'),
  'total' : fields.function(_addition, string='Tot',type='float'),