Browse Source

[IMP] define a shorter code to set 'compatible_tree' variable

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

4
tree_view_record_id/__openerp__.py

@ -25,9 +25,9 @@
'category': 'Other modules', 'category': 'Other modules',
'sequence': 10, 'sequence': 10,
'author': 'Akretion', 'author': 'Akretion',
'summary': "Add id field to tree views",
'summary': "Adds id field to tree views",
'description': """ 'description': """
Add Id field to all non arborescent tree views.
Adds Id field to all non arborescent tree views.
Id field is the primary key of the table (Odoo model). 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. Arborescent views like 'Products by Category' or 'Chart of accounts' haven't this field included.
""", """,

4
tree_view_record_id/orm.py

@ -38,13 +38,11 @@ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None,
self, cr, uid, view_id=view_id, view_type=view_type, context=context, self, cr, uid, view_id=view_id, view_type=view_type, context=context,
toolbar=toolbar, submenu=submenu) toolbar=toolbar, submenu=submenu)
if view_type == 'tree': if view_type == 'tree':
compatible_tree = False
compatible_tree = res.get('field_parent', True) is False
# Tree views with res['field_parent'] different from False # Tree views with res['field_parent'] different from False
# 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 res.get('field_parent', True) is False:
compatible_tree = True
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