Comment 5 for bug 997316

Revision history for this message
Ronald Portier (Therp) (rportier1962) wrote :

The bug can also occur when generating a new opening balance. The main problem is that the selection for currency accounts can result in records with a not null currency, but a null amount.

The solution is to change the selection in account.py (lines may have changed):

1526 #adjust also the amount in currency if needed
1527 cr.execute("select currency_id, sum(amount_currency) as amount_currency from account_move_line where move_id = %s and currency_id is not null and amount_currency is not null group by currency_id", (move.id,))
1528 for row in cr.dictfetchall():
1529 currency_id = currency_obj.browse(cr, uid, row['currency_id'], context=context)
1530 if not currency_obj.is_zero(cr, uid, currency_id, row['amount_currency']):
1531 amount_currency = row['amount_currency'] * -1

In the above fragment I added " and amount_currency is not null" to line 1527. I will create a merge request for 6.1. maybe later for 7.0 as I think it will have the same problems.

Crash report:

Server Traceback (most recent call last):

  File "/home/oerttrprd61/openerp-web/addons/web/common/http.py", line
593, in send

    return openerp.netsvc.dispatch_rpc(service_name, method, args)

  File "/home/oerttrprd61/bzr/openobject-server/openerp/netsvc.py", line
360, in dispatch_rpc

    result = ExportService.getService(service_name).dispatch(method, params)

  File
"/home/oerttrprd61/bzr/openobject-server/openerp/service/web_services.py",
line 586, in dispatch

    res = fn(db, uid, *params)

  File "/home/oerttrprd61/bzr/openobject-server/openerp/osv/osv.py",
line 186, in execute_kw

    return self.execute(db, uid, obj, method, *args, **kw or {})

  File "/home/oerttrprd61/bzr/openobject-server/openerp/osv/osv.py",
line 129, in wrapper

    return f(self, dbname, *args, **kwargs)

  File "/home/oerttrprd61/bzr/openobject-server/openerp/osv/osv.py",
line 195, in execute

    res = self.execute_cr(cr, uid, obj, method, *args, **kw)

  File "/home/oerttrprd61/bzr/openobject-server/openerp/osv/osv.py",
line 183, in execute_cr

    return getattr(object, method)(cr, uid, *args, **kw)

  File
"/home/oerttrprd61/openobject-addons/account/wizard/account_fiscalyear_close.py",
line 256, in data_save

    obj_acc_move.validate(cr, uid, [move_id], context=context)

  File "/home/oerttrprd61/openobject-addons/account/account.py", line
1635, in validate

    self._centralise(cr, uid, move, 'debit', context=context)

  File "/home/oerttrprd61/openobject-addons/account/account.py", line
1511, in _centralise

    }, context)

  File
"/home/oerttrprd61/openobject-addons/account/account_move_line.py", line
1395, in create

    tmp = move_obj.validate(cr, uid, [vals['move_id']], context)

  File "/home/oerttrprd61/openobject-addons/account/account.py", line
1635, in validate

    self._centralise(cr, uid, move, 'debit', context=context)

  File "/home/oerttrprd61/openobject-addons/account/account.py", line
1530, in _centralise

    if not currency_obj.is_zero(cr, uid, currency_id,
row['amount_currency']):

  File
"/home/oerttrprd61/bzr/openobject-server/openerp/addons/base/res/res_currency.py",
line 172, in is_zero

    return float_is_zero(amount, precision_rounding=currency.rounding)

  File
"/home/oerttrprd61/bzr/openobject-server/openerp/tools/float_utils.py",
line 97, in float_is_zero

    return abs(float_round(value, precision_rounding=epsilon)) < epsilon

  File
"/home/oerttrprd61/bzr/openobject-server/openerp/tools/float_utils.py",
line 66, in float_round

    normalized_value = value / rounding_factor # normalize

TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'