Field company_id not found in browse_record(account.account, 15)

Bug #620481 reported by James Jesudason
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
Vinay Rana (OpenERP)
Nominated for Trunk by James Jesudason

Bug Description

The following error is generated when selecting a product on the invoice_line_form.

I've tracked the problem down to line 1303:
    app_acc_in = account_obj.browse(cr, uid, in_pro_id)[0]

The code is trying to retrieve the account.account record from an ir.property record. However, it is using the ir.property record's ID (15 in my case), instead getting the account.account.id from the ir.property record (which is 99 in my case). The current code won't give an error on some databases if an account.account record exists that has an ID that is the same as the ir.property.id - but the code is wrong.

The code should get the account.account.id from the ir.property record, and use that in the browse statement. Something like this:
                # Get the fields from the ir.property record
                my_value = property_obj.read(cr,uid,in_pro_id,['name','value_reference','res_id'])
                # Parse the value_reference field to get the ID of the account.account record
                account_id = int (my_value[0]["value_reference"].split(",")[1])
                # Use the ID of the account.account record in the browse for the account.account record
                app_acc_in = account_obj.browse(cr, uid, account_id)[0]

(I imagine that there is a utility function somewhere to parse the value_reference field on a ir.property, but I don't know what that is).

bzr addons version: 4729

Environment Information :
System : Linux-2.6.32-24-generic-i686-with-Ubuntu-10.04-lucid
OS Name : posix
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid
Operating System Release : 2.6.32-24-generic
Operating System Version : #39-Ubuntu SMP Wed Jul 28 06:07:29 UTC 2010
Operating System Architecture : 32bit
Operating System Locale : en_GB.UTF8
Python Version : 2.6.5
OpenERP-Client Version : 6.0dev
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/home/jjesudason/Documents/Development/openerp6/server/bin/netsvc.py", line 429, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/jjesudason/Documents/Development/openerp6/server/bin/service/web_services.py", line 589, in dispatch
    res = fn(db, uid, *params)
  File "/home/jjesudason/Documents/Development/openerp6/server/bin/osv/osv.py", line 57, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/jjesudason/Documents/Development/openerp6/server/bin/osv/osv.py", line 133, in execute
    res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/jjesudason/Documents/Development/openerp6/server/bin/osv/osv.py", line 123, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/jjesudason/Documents/Development/openerp6/addons/account/invoice.py", line 1327, in product_id_change
    if app_acc_in.company_id.id != company_id and app_acc_exp.company_id.id != company_id:
  File "/home/jjesudason/Documents/Development/openerp6/server/bin/osv/orm.py", line 279, in __getattr__
    raise AttributeError(e)
AttributeError: 'Field company_id not found in browse_record(account.account, 15)'

Related branches

Revision history for this message
James Jesudason (jamesj) wrote :

Forgot to mention that the problem is in account/invoice.py.

Also, slight amendment to my code (added [] around account_id in the browse call):

                # Get the fields from the ir.property record
                my_value = property_obj.read(cr,uid,in_pro_id,['name','value_reference','res_id'])
                # Parse the value_reference field to get the ID of the account.account record
                account_id = int (my_value[0]["value_reference"].split(",")[1])
                # Use the ID of the account.account record in the browse for the account.account record
                app_acc_in = account_obj.browse(cr, uid, [account_id])[0]

Changed in openobject-addons:
assignee: nobody → JMA(Open ERP) (jma-openerp)
Revision history for this message
Jim Norman (jim-jsnorman) wrote :

Please see fix in Bug #627150

Changed in openobject-addons:
assignee: JMA(Open ERP) (jma-openerp) → vra (openerp) (vra-openerp)
status: New → Confirmed
milestone: none → 6.0
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) wrote :

This has been fixed from 4916 <email address hidden> revision.
Thanks.

Changed in openobject-addons:
importance: Undecided → Medium
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.