Error when group by or order by with fields inherit from product

Bug #823691 reported by tnbui
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

This bug happened on v6.

In hotel module, I have a Room object which is inherited from "product.product". I got below error message when I tried to "order by" or group by field "categ_id".

I searched around and found bug https://bugs.launchpad.net/openobject-client-web/+bug/362280 which may related to this error.

Error message:

Traceback (most recent call last):
  File "/usr/local/openerp-fullmoon-integration/current/server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/usr/local/openerp-fullmoon-integration/current/server/bin/service/web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "/usr/local/openerp-fullmoon-integration/current/server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/local/openerp-fullmoon-integration/current/server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/local/openerp-fullmoon-integration/current/server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/local/openerp-fullmoon-integration/current/server/bin/osv/orm.py", line 1743, in search
    return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
  File "/usr/local/openerp-fullmoon-integration/current/server/bin/osv/orm.py", line 4012, in _search
    order_by = self._generate_order_by(order, query)
  File "/usr/local/openerp-fullmoon-integration/current/server/bin/osv/orm.py", line 3978, in _generate_order_by
    order_column = parent_obj._columns[order_field]
KeyError: 'categ_id'

Tags: maintenance

Related branches

Revision history for this message
Dhruti Shastri(OpenERP) (dhs-openerp) wrote :

Hello tnbui,

I have checked the same issue at my end but it seems working perfectly fine.

Would you please update the code and recheck ?

Please let us know with the more information if you still face the same error.

Thanks.

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
tnbui (tnbui-it) wrote :

Hello,

I did get the latest source code to check and got the same problem. Below are the steps to reproduce:

1. Create new database
2. Install module "hotel" (from extra-v6)
3. Go to menu Hotel Management > Configuration > Room Types > Rooms
4. Make sure there is at least 1 records in the list of Rooms
5. Click to column Name (or Category) to order the list, then the error appears.

Revision history for this message
Dhruti Shastri(OpenERP) (dhs-openerp) wrote :

Hello,

The problem is still exist. I have checked the same scenario.

When trying to _inherits in 3 level. i.e. product.template-> product.product->hotel.rooms.

It is not working as expected. I have attached the video for proof.

Thank you for pointing this issue.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: Incomplete → Confirmed
Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello tnbui,

Thanks for reporting !

The issue hass been fixes at lp:~openerp-dev/openobject-server/trunk-bug-823691-nch and will be merged soon to the trunk server.

Please provide your feedback !

Thanks,

Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
tnbui (tnbui-it) wrote :

Hello Naresh,

Thks for your fixed!

Sorry for late response, but it took me a lot of time to test this problem again. I tried to create a new database to test this problem. But after I installed module "hotel", I couldn't create any "Room" (it displayed nothing when I clicked on button "Create")

Btw, I test on my old database and everything is ok now.

Have a nice day,
Tu

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello tnbui,

Thanks for your feedback !

Yes you are right...a small change is still required on the fix and its already commented on the merge proposal. When the fix will be merged to trunk server that change will be also included. For time being you can test it by making these change in orm.py @ line 4051 (table, col, col_detail) = self._inherit_fields[v] just replace this line by (table, col, col_detail, original_parent) = self._inherit_fields[v]. along with the merge proposal changes.

Sorry for the inconvenience caused.

Thanks

Revision history for this message
tnbui (tnbui-it) wrote :

Hello Naresh,

I found another problem with multi inherit from product. I tried to duplicate a room, then input a new name for duplicated record. After that, I got 2 records with the same name.

Below is the steps to reproduce:
1. Create a Room name: "Test 1"
2. Duplicate room "Test 1", then change the name to "Test 2"
3. Now if you go to the list of Rooms, you will see there are 2 records with name "Test 2"

After took a look on the database, I found that the Product Template is not created when duplicating a Room. It also meant that 2 Rooms are using the same Product Template.

Please let me know if you want me to create a new bug for this one.

Regards,
Tu

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello tnbui ,

Thanks for pointing out the issue.

No you don't need to file a separate bug as the problem is just the extension of the original problem I will incorporate the fix in the same merge proposal.

About the bug yes you are absolutely right ! As in your case its a multi level inheritance and the copy method was not removing recursively the inherited class id's from the data. we need to remove that and create a new record in all base class class too . It was just doing it for the first level. The merge proposal is update to have the fix for copy problem too with the changes I marked in #6.

Thanks,

Revision history for this message
tnbui (tnbui-it) wrote :

Hello Naresh,

Thks for your fixed! It works now!

Have a nice day,
Tu

Revision history for this message
tnbui (tnbui-it) wrote :

Hello Naresh,

Just 1 more comment about this problem, if I try to set "_order = 'name'" in object "hotel.room" to order rooms by name, I get below error message when viewing the list of Rooms.

IMHO, this feature is also good to have.

Thanks,
Tu

Traceback (most recent call last):
  File "/home/tubui/source_code/trunk6-new/server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/tubui/source_code/trunk6-new/server/bin/service/web_services.py", line 599, in dispatch
    res = fn(db, uid, *params)
  File "/home/tubui/source_code/trunk6-new/server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/tubui/source_code/trunk6-new/server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/tubui/source_code/trunk6-new/server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/tubui/source_code/trunk6-new/server/bin/osv/orm.py", line 1743, in search
    return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
  File "/home/tubui/source_code/trunk6-new/server/bin/osv/orm.py", line 4045, in _search
    cr.execute('SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str, where_clause_params)
  File "/home/tubui/source_code/trunk6-new/server/bin/sql_db.py", line 78, in wrapper
    return f(self, *args, **kwargs)
  File "/home/tubui/source_code/trunk6-new/server/bin/sql_db.py", line 131, in execute
    res = self._obj.execute(query, params)
ProgrammingError: column "name" does not exist
LINE 1: SELECT "hotel_room".id FROM "hotel_room" ORDER BY name limi...

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello, tnbui ,

Thanks for the problem you reported in your comment #10 but as this needs a big refactoring in the current framework architecture so I would like you to open a separate report for this one.

Thanks again for your work !

Revision history for this message
tnbui (tnbui-it) wrote :

Hi Naresh,

I fired another bug for that at https://bugs.launchpad.net/openobject-server/+bug/858006

Regards,
Tu

Revision history for this message
Yaiza Bailen (ybailen) wrote :

Hi,

I'm getting the same error working with version 6.0.3.
openerp-server: release 3533

I have 3 levels of inheritance as well hr_employee -> hr_employee_employee -> hr_employee_secure and in the tree view I can't order the columns and I get the error

ERROR:web-services:Uncaught exception
Traceback (most recent call last):
  File "/home/yaiza/Development/openerp-6.0/server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/yaiza/Development/openerp-6.0/server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/yaiza/Development/openerp-6.0/server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/yaiza/Development/openerp-6.0/server/bin/osv/orm.py", line 1745, in search
    return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
  File "/home/yaiza/Development/openerp-6.0/server/bin/osv/orm.py", line 4018, in _search
    order_by = self._generate_order_by(order, query)
  File "/home/yaiza/Development/openerp-6.0/server/bin/osv/orm.py", line 3984, in _generate_order_by
    order_column = parent_obj._columns[order_field]
KeyError: 'department_id'

Is this bug going to be merged in this stable version?

I have checked the same module with version 6.1 openerp-server release 3778 and it works perfectly there with the fix that you did, thanks for that!

Regards,
Yaiza

tags: added: maintenance
Revision history for this message
Ravi Gohil (OpenERP) (rgo-openerp) wrote :

Fixed for Stable,

lp:~openerp-dev/openobject-server/6.0-opw-35611-rgo
Revision ID: <email address hidden>
Revision 3539

Best regards.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Correcting status, this was fixed in trunk at revision[1] a while ago.

[1] rev. 3627 rev-id: <email address hidden>

Changed in openobject-server:
milestone: none → 6.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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