Browse Source

[FIX] exclude field addition to tree views buit on transient models

pull/9/head
david.beal@akretion.com 11 years ago
parent
commit
c9be267485
  1. 9
      tree_view_record_id/__openerp__.py
  2. 4
      tree_view_record_id/orm.py

9
tree_view_record_id/__openerp__.py

@ -27,9 +27,12 @@
'author': 'Akretion', 'author': 'Akretion',
'summary': "Adds id field to tree views", 'summary': "Adds id field to tree views",
'description': """ 'description': """
Adds Id field to all non arborescent tree views.
Id field is the primary key of the table (Odoo model).
Arborescent views like 'Products by Category' or 'Chart of accounts' haven't this field included.
Adds Id field in all tree views of any modules/models, except:
* Arborescent tree views like 'Products by Category', 'Chart of accounts', etc.
* Tree views (like in wizard 'Change password') built on transient models which don't have this column in their table.
Id field is the primary key of standard sql tables defined by the orm (Odoo model).
""", """,
'website': 'http://www.akretion.com', 'website': 'http://www.akretion.com',
'depends': [ 'depends': [

4
tree_view_record_id/orm.py

@ -43,6 +43,10 @@ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None,
# looks like 'Products by Category'. # looks like 'Products by Category'.
# We don't modify these views # We don't modify these views
# to avoid to break them (js error) # to avoid to break them (js error)
if '_transient_max_count' in self.pool[res['model']].__dict__.keys():
# model with '_transient_max_count' key are transient model
# transient models haven't 'id' column in mostly case
compatible_tree = False
if compatible_tree and DUMMY_MODEL in self.pool.models.keys(): if compatible_tree and DUMMY_MODEL in self.pool.models.keys():
doc = etree.XML(res['arch']) doc = etree.XML(res['arch'])
if doc.xpath("//tree") and len(doc.xpath("//field[@name='id']")) == 0: if doc.xpath("//tree") and len(doc.xpath("//field[@name='id']")) == 0:

Loading…
Cancel
Save