我在獲取函數字段以計算折扣,稅收和總計在一個列表中遇到問題。如何計算openerp中的函數字段和db字段
我與OpenERP的7這裏工作是我的代碼:
def _total(self,cr,uid,ids,field_names,args,context=None):
res = {}
for record in self.browse(cr,uid,ids,context=context):
res[record.id]={
'total': record.cantidad * record.precioe,
'total1': record.total * record.descuento/100,
'total2': record.total - record.total1,
'iva': record.total2 * 16/100,
'gran_total': record.iva + record.total2,
}
return res
和
'cantidad': fields.integer('Cantidad', multi='calc'),
'precioe': fields.float('Costo', multi='calc'),
#'precio_equipo': fields.related('equipo', 'precio', string='Precio', type='float', readonly=True),
'total': fields.function(_total, type='float', method=True, string='Total', store=True, multi='calc'),
'descuento': fields.integer('Descuento', multi='calc'),
'total1': fields.function(_total, type='float', method=True, string='Total descuento', store=True, multi='calc'),
'total2': fields.function(_total, type='float', method=True, string='subtotal', store=True, multi='calc'),
'iva': fields.function(_total, type='float', method=True, string='IVA', store=True, multi='calc'),
'gran_total': fields.function(_total, type='float', method=True, string='Total', store=True, multi='calc'),
}
,我只能算總分第一名,其他值出現在0什麼IM我做錯了?
謝謝你,那工作,你很棒 – user3364356