Reviewers: ,
Please review this at http://codereview.tryton.org/358001/
Affected files:
M trytond/ir/module/module.py
M trytond/ir/module/module.xml
Index: trytond/ir/module/module.py
===================================================================
--- a/trytond/ir/module/module.py
+++ b/trytond/ir/module/module.py
@@ -11,6 +11,46 @@
from trytond.transaction import Transaction
from trytond.pyson import Eval
+class ModuleData(ModelSQL, ModelView):
+ "Module Data"
+ _name = 'ir.module.data'
+ _description = __doc__
+ module = fields.Many2One('ir.module.module', 'Module', readonly=True,
+ required=True)
+ model = fields.Many2One('ir.model', 'Model', readonly=True,
+ required=True)
+ value = fields.Reference('Value', selection='get_models',
readonly=True,
+ required=True)
+
+ def table_query(self):
+ pool = Pool()
+ query = (
+ 'SELECT '
+ 'data.id AS id, '
+ 'data.create_uid AS create_uid, '
+ 'data.create_date AS create_date, '
+ 'data.write_uid AS write_uid, '
+ 'data.write_date AS write_date, '
+ 'module.id AS module, '
+ 'model.id AS model, '
+ "model.model || ',' || data.db_id::VARCHAR AS value "
+ 'FROM '
+ '"' + pool.get('ir.model.data')._table + '" data, '
+ '"' + pool.get('ir.model')._table + '" model, '
+ '"' + pool.get('ir.module.module')._table + '" module '
+ 'WHERE '
+ 'data.model = model.model AND '
+ 'data.module = module.name'
+ )
+ return (query, [])
+
+ def get_models(self):
+ cursor = Transaction().cursor
+ cursor.execute('SELECT model, name FROM ir_model ORDER BY name
ASC')
+ return cursor.fetchall()
+
+ModuleData()
+
class Module(ModelSQL, ModelView):
"Module"
@@ -35,6 +75,11 @@
('to remove', 'To be removed'),
('to install', 'To be installed'),
], string='State', readonly=True)
+ data = fields.One2Many('ir.module.data', 'module', 'Data')
+ models = fields.Function(fields.One2Many('ir.model', None, 'Models'),
+ 'get_models')
+ fields = fields.Function(fields.One2Many('ir.model.field',
None, 'Fields'),
+ 'get_fields')
def __init__(self):
super(Module, self).__init__()
@@ -125,6 +170,22 @@
childs[dep.module.id].append(child.id)
return childs
+ def get_models(self, ids, name):
+ pool = Pool()
+ model_obj = pool.get('ir.model')
+ res = {}
+ for module in self.browse(ids):
+ res[module.id] = model_obj.search([('module', '=',
module.name)])
+ return res
+
+ def get_fields(self, ids, name):
+ pool = Pool()
+ field_obj = pool.get('ir.model.field')
+ res = {}
+ for module in self.browse(ids):
+ res[module.id] = field_obj.search([('module', '=',
module.name)])
+ return res
+
def delete(self, ids):
if not ids:
return True
Index: trytond/ir/module/module.xml
===================================================================
--- a/trytond/ir/module/module.xml
+++ b/trytond/ir/module/module.xml
@@ -4,6 +4,36 @@
<tryton>
<data>
<menuitem name="Modules" parent="menu_administration"
id="menu_modules"/>
+ <record model="ir.ui.view" id="module_data_view_form">
+ <field name="model">ir.module.data</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <![CDATA[
+ <form string="Module Data">
+ <label name="module"/>
+ <field name="module"/>
+ <label name="model"/>
+ <field name="model"/>
+ <label name="value"/>
+ <field name="value" colspan="3"/>
+ </form>
+ ]]>
+ </field>
+ </record>
+ <record model="ir.ui.view" id="module_data_view_tree">
+ <field name="model">ir.module.data</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <![CDATA[
+ <tree string="Module Data">
+ <field name="module"/>
+ <field name="model"/>
+ <field name="value"/>
+ </tree>
+ ]]>
+ </field>
+ </record>
+
<record model="ir.ui.view" id="module_view_form">
<field name="model">ir.module.module</field>
<field name="type">form</field>
@@ -28,6 +58,12 @@
<page string="Dependencies" col="1"
id="dependencies">
<field name="dependencies"/>
</page>
+ <page string="Extra Information" col="2" id="extra"
+ states="{'invisible':
Not(Equal(Eval('state'), 'installed'))}">
+ <field name="data"/>
+ <field name="models"/>
+ <field name="fields" colspan="2"/>
+ </page>
</notebook>
<label name="state"/>
<field name="state" readonly="1"/>
--
[email protected] mailing list