← Back to team overview

openerp-india team mailing list archive

[Bug 955092] [NEW] [account] onchange_line error when debit and credit values not changed

 

Public bug reported:

The following error is generated if a journal item (debit/credit line)
is changed on a journal entry, but no change is made to the debit and
credit values:

Server Traceback (most recent call last):
  File "/home/jjesudason/Documents/Development/openerp/trunk/web/addons/web/common/http.py", line 592, in send
    result = openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/netsvc.py", line 360, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/service/web_services.py", line 572, in dispatch
    res = fn(db, uid, *params)
  File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/osv/osv.py", line 167, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/osv/osv.py", line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/osv/osv.py", line 164, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/jjesudason/Documents/Development/openerp/trunk/addons/account/account.py", line 1367, in onchange_line_id
    balance += (line[2]['debit'] or 0.00)- (line[2]['credit'] or 0.00)
KeyError: 'debit'

The problem is with the onchange_line method in account/account.py:

    def onchange_line_id(self, cr, uid, ids, line_ids, context=None):
        balance = 0.0
        for line in line_ids:
            if line[2]:
                balance += (line[2]['debit'] or 0.00)- (line[2]['credit'] or 0.00)
        return {'value': {'balance': balance}}

This should do the following instead:

    def onchange_line_id(self, cr, uid, ids, line_ids, context=None):
        balance = 0.0
        for line in line_ids:
            if line[2]:
                balance += (line[2].get('debit') or 0.00)- (line[2].get('credit') or 0.00)
        return {'value': {'balance': balance}}

Steps to reproduce:
1. Duplicate a Journal Entry.
2. Edit one of the lines on the journal entry and only change the account.
3. Save the line.

This will generate the error message.

** Affects: openobject-addons
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/955092

Title:
  [account] onchange_line error when debit and credit values not changed

Status in OpenERP Addons (modules):
  New

Bug description:
  The following error is generated if a journal item (debit/credit line)
  is changed on a journal entry, but no change is made to the debit and
  credit values:

  Server Traceback (most recent call last):
    File "/home/jjesudason/Documents/Development/openerp/trunk/web/addons/web/common/http.py", line 592, in send
      result = openerp.netsvc.dispatch_rpc(service_name, method, args)
    File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/netsvc.py", line 360, in dispatch_rpc
      result = ExportService.getService(service_name).dispatch(method, params)
    File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/service/web_services.py", line 572, in dispatch
      res = fn(db, uid, *params)
    File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/osv/osv.py", line 167, in execute_kw
      return self.execute(db, uid, obj, method, *args, **kw or {})
    File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/osv/osv.py", line 121, in wrapper
      return f(self, dbname, *args, **kwargs)
    File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/osv/osv.py", line 176, in execute
      res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/home/jjesudason/Documents/Development/openerp/trunk/server/openerp/osv/osv.py", line 164, in execute_cr
      return getattr(object, method)(cr, uid, *args, **kw)
    File "/home/jjesudason/Documents/Development/openerp/trunk/addons/account/account.py", line 1367, in onchange_line_id
      balance += (line[2]['debit'] or 0.00)- (line[2]['credit'] or 0.00)
  KeyError: 'debit'

  The problem is with the onchange_line method in account/account.py:

      def onchange_line_id(self, cr, uid, ids, line_ids, context=None):
          balance = 0.0
          for line in line_ids:
              if line[2]:
                  balance += (line[2]['debit'] or 0.00)- (line[2]['credit'] or 0.00)
          return {'value': {'balance': balance}}

  This should do the following instead:

      def onchange_line_id(self, cr, uid, ids, line_ids, context=None):
          balance = 0.0
          for line in line_ids:
              if line[2]:
                  balance += (line[2].get('debit') or 0.00)- (line[2].get('credit') or 0.00)
          return {'value': {'balance': balance}}

  Steps to reproduce:
  1. Duplicate a Journal Entry.
  2. Edit one of the lines on the journal entry and only change the account.
  3. Save the line.

  This will generate the error message.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/955092/+subscriptions


Follow ups

References