Synchronize translation terms crash when abstract models are used

Bug #1029344 reported by Guewen Baconnier @ Camptocamp
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP's Framework R&D
OpenERP Community Backports (Server)
Status tracked in 7.0
6.1
Fix Committed
Medium
Yann Papouin
7.0
New
Undecided
Unassigned

Bug Description

Hello,

If you have at least one abstract model in a module, the synchronization of terms to translate fails.

To reproduce it, you'll need to declare an abstract model :

    class an_abstract_model(AbstractModel):
        _name = 'an.abstract.model'
        _columns = {}

When you launch the synchronization of translated terms, you'll get an error, with a traceback similar to the one below.

, in query SELECT "an_abstract_model".id FROM "an_abstract_model" ORDER BY sequence
2012-07-26 08:27:07,748 1925 ERROR ? openerp.osv.osv: Uncaught exception
Traceback (most recent call last):
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/osv/osv.py", line 121, in
    return f(self, dbname, *args, **kwargs)
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/osv/osv.py", line 176, in
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/osv/osv.py", line 164, in
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/addons/base/module/wizard
    tools.trans_export(this.lang, ['all'], buf, 'csv', cr)
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/tools/translate.py", line
    trans = trans_generate(lang, modules, cr)
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/tools/translate.py", line
    ids = objmodel.search(cr, uid, [])
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/osv/orm.py", line 2245, i
    return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/osv/orm.py", line 4599, i
    cr.execute('SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + o
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/sql_db.py", line 152, in
    return f(self, *args, **kwargs)
  File "/home/gbaconnier/code/instances/openerp_abstract/trunk/src/server/openerp/sql_db.py", line 212, in
    res = self._obj.execute(query, params)
ProgrammingError: relation "an_abstract_model" does not exist
LINE 1: SELECT "an_abstract_model".id FROM "an_abstract_model" ORDER B...

Related branches

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Merge proposal done on the linked branches.

description: updated
Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello Guewen Baconnier ,

I have check this issue with latest trunk but I did not face any
problem as you mention in bug report.So would you please
provide more information regarding this issue.

I have declare abstract class in account.py and done synchronize.

class an_abstarct_model(osv.AbstractModel):
    _name = 'an.abstract.model'
    _columns = {}

Thanks and waiting for your reply!

Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hello,

Sorry, I tried to reproduce it again, and I'm wrong in my reproduction step.

You need to have at least one translatable field in the model to encounter the bug.

class an_abstract_model(AbstractModel):
    _name = 'an.abstract.model'
    _columns = {
        'name': fields.char('Name', translate=True)
    }

Thanks & Best Regards

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :
Changed in openobject-server:
importance: Undecided → Medium
status: Incomplete → Confirmed
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
Revision history for this message
ajay javiya (OpenERP) (aja-openerp) wrote :

Hello Guewen Baconnier ,
we have traced and reproduce issue and have fixed problem in branch
 lp:~openerp-dev/openobject-server/trunk-bug-1029344-aja .

I have seen your merge proposal but we can not adopt it as it simply ignores all _auto = False models, so i can say that all statistical reports model translation are ignored, moreover auto falg will be trick to give more flaxibility over table creation. and We need or check in all condition.
Let me know If I am missing something.
Thank You

Changed in openobject-server:
status: Confirmed → In Progress
status: In Progress → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

Hi Guewen,

Does setting _register=False when defining your own abstract model solve the problem?

As said by Ajay, filter models when _auto is False would not be accurate enough (i.e. a model can have its _auto attribute to false but still exists in database, this is the case for some reports. The _auto attribute only means the ORM should not create the table but the model code can do it in its init() method).

We have to better document the behavior of the _register flag. If the suggestion above works, please edit the bug report saying we have to update the comments for _register (instead of just dropping dead the bug report). (The comment will be better than nothing, while we still have to create the proper ORM documentation.)

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.