This question has been flagged
2 Replies
6562 Views

When i access to the form with no rows in the oneToMany field, openErp return:

Uncaught Error: [_.sprintf] expecting number but found array

This error caused by this function:

def _total_presupuestos(self, cr, uid, ids, field_name, field_value, arg, context=None):
    result={} 
    total=0
    invoice_obj = self.pool.get('sat.incidencias')
    for records_invoice in invoice_obj.browse(cr, uid, ids, context=context):
        for records_invoice_lines in records_invoice.presupuesto_id:
            total += records_invoice_lines.pv_sin_impuestos
            result[records_invoice.id] = total
    return result

Help, please

Avatar
Discard

Can you post che _columns content, please?

Best Answer

Try this:

def _total_presupuestos(self, cr, uid, ids, field_name, field_value, arg, context=None):
    result={} 
    if not ids:
        return result
    total=0.0
    invoices = self.pool.get('sat.incidencias').browse(cr, uid, ids, context=context)
    for records_invoice in invoices:
        for records_invoice_lines in records_invoice.presupuesto_id:
            total += records_invoice_lines.pv_sin_impuestos
            result[records_invoice.id] = total
    return result
Avatar
Discard
Author Best Answer

Thanks... Works Fine!

Avatar
Discard