Commit 5ab6c54c authored by jssuzanne's avatar jssuzanne
Browse files

merge fields selection with view

parent 23500030781b
#!/usr/bin/env python
#==============================================================================
# =
# anybus module for OpenERP, Use the lib anybus and broker rabbitmq to send and receive data
# Copyright (C) 2012 Anybox (<http://http://anybox.fr>)
# Jean-Sebastien SUZANNE <jssuzanne@anybox.fr>
# =
# This file is a part of anybus
# =
# anybus is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License v3 or later
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# =
# anybus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License v3 or later for more details.
# =
# You should have received a copy of the GNU Affero General Public License
# v3 or later along with this program.
# If not, see <http://www.gnu.org/licenses/>.
# =
#==============================================================================
# -*- coding: utf-8 -*-
#flake8: noqa
import fields_selection
......
#!/usr/bin/env python
#==============================================================================
# =
# anybus module for OpenERP, Use the lib anybus and broker rabbitmq to send and receive data
# Copyright (C) 2012 Anybox (<http://http://anybox.fr>)
# Jean-Sebastien SUZANNE <jssuzanne@anybox.fr>
# =
# This file is a part of anybus
# =
# anybus is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License v3 or later
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# =
# anybus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License v3 or later for more details.
# =
# You should have received a copy of the GNU Affero General Public License
# v3 or later along with this program.
# If not, see <http://www.gnu.org/licenses/>.
# =
#==============================================================================
{
'name': 'Fields selection',
'version': '0.2',
'version': '0.3',
'category': 'Anybus/Utility',
'description': """
Add tree of fields to select one export
......@@ -35,17 +12,13 @@ Add tree of fields to select one export
'depends': [
'base',
],
'init_xml': [
],
'update_xml': [
'security/ir.model.access.csv',
],
'demo_xml': [
'view/fields_selection.xml',
],
'installable': True,
'application': False,
'auto_install': False,
'license': 'AGPL-3',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
......@@ -2,6 +2,7 @@
from osv import osv, fields
class AnybusFieldsSelection(osv.Model):
_name = 'anybus.fields.selection'
_description = 'Anybus fields selection'
......@@ -10,10 +11,13 @@ class AnybusFieldsSelection(osv.Model):
_columns = {
'model_id': fields.many2one('ir.model', 'Model', required=True),
'relation_id': fields.many2one('ir.model', 'Relation'),
'sub_field_id': fields.many2one('ir.model.fields', 'Field', required=True),
'sub_field_id': fields.many2one(
'ir.model.fields', 'Field', required=True),
'ttype': fields.char('ttype', size=64),
'parent_id': fields.many2one('anybus.fields.selection', 'Parent', ondelete="cascade"),
'child_ids': fields.one2many('anybus.fields.selection', 'parent_id', 'Child'),
'parent_id': fields.many2one(
'anybus.fields.selection', 'Parent', ondelete="cascade"),
'child_ids': fields.one2many(
'anybus.fields.selection', 'parent_id', 'Child'),
'add_db_id': fields.boolean('DB ID'),
'add_xml_id': fields.boolean('XML ID'),
}
......@@ -26,10 +30,13 @@ class AnybusFieldsSelection(osv.Model):
def onchange_sub_field_id(self, cr, uid, ids, sub_field_id, context=None):
res = {}
if sub_field_id:
field = self.pool.get('ir.model.fields').read(cr, uid, sub_field_id, ['ttype', 'relation'], context=context)
field = self.pool.get('ir.model.fields').read(
cr, uid, sub_field_id, ['ttype', 'relation'], context=context)
value = {'ttype': field['ttype']}
if field['relation']:
value['relation_id'] = self.pool.get('ir.model').search(cr, uid, [('model', '=', field['relation'])], context=context)[0]
value['relation_id'] = self.pool.get('ir.model').search(
cr, uid, [('model', '=', field['relation'])],
context=context)[0]
res['value'] = value
return res
......@@ -44,17 +51,17 @@ class AnybusFieldsSelection(osv.Model):
if this.add_xml_id:
result.update({field_name + '/id': field_description})
for child in this.child_ids:
result.update(self.__get_fields_name(cr, uid, child, parent=field_name + '/', context=context))
result.update(self.__get_fields_name(
cr, uid, child, parent=field_name + '/', context=context))
else:
result.update({field_name: field_description})
return result
def get_fields_name(self, cr, uid, ids, context=None):
result = {}
for this in self.browse(cr, uid, ids, context=context):
result.update(self.__get_fields_name(cr, uid, this, context=context))
result.update(self.__get_fields_name(
cr, uid, this, context=context))
return result
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
......@@ -20,12 +20,18 @@
<field name="model_id" invisible="1"/>
<field name="relation_id" invisible="1"/>
<field name="ttype" invisible="1"/>
<field name="sub_field_id" domain="[('model_id', '=', model_id)]" on_change="onchange_sub_field_id(sub_field_id, context)"/>
<field name="sub_field_id"
domain="[('model_id', '=', model_id)]"
on_change="onchange_sub_field_id(sub_field_id, context)"/>
<newline/>
<group colspan="4">
<field name="add_db_id" attrs="{'invisible': [('ttype', 'not in', ('many2one', 'one2many', 'many2many'))]}"/>
<field name="add_xml_id" attrs="{'invisible': [('ttype', 'not in', ('many2one', 'one2many', 'many2many'))]}"/>
<field name="child_ids" nolabel="1" colspan="4" context="{'default_model_id': relation_id}" attrs="{'invisible': [('ttype', 'not in', ('many2one', 'one2many', 'many2many'))]}"/>
<field name="add_db_id"
attrs="{'invisible': [('ttype', 'not in', ('many2one', 'one2many', 'many2many'))]}"/>
<field name="add_xml_id"
attrs="{'invisible': [('ttype', 'not in', ('many2one', 'one2many', 'many2many'))]}"/>
<field name="child_ids" nolabel="1" colspan="4"
context="{'default_model_id': relation_id}"
attrs="{'invisible': [('ttype', 'not in', ('many2one', 'one2many', 'many2many'))]}"/>
</group>
</form>
</field>
......
#!/usr/bin/env python
#==============================================================================
# =
# anybus module for OpenERP, Use the lib anybus and broker rabbitmq to send and receive data
# Copyright (C) 2012 Anybox (<http://http://anybox.fr>)
# Jean-Sebastien SUZANNE <jssuzanne@anybox.fr>
# =
# This file is a part of anybus
# =
# anybus is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License v3 or later
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# =
# anybus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License v3 or later for more details.
# =
# You should have received a copy of the GNU Affero General Public License
# v3 or later along with this program.
# If not, see <http://www.gnu.org/licenses/>.
# =
#==============================================================================
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
#!/usr/bin/env python
#==============================================================================
# =
# anybus module for OpenERP, Use the lib anybus and broker rabbitmq to send and receive data
# Copyright (C) 2012 Anybox (<http://http://anybox.fr>)
# Jean-Sebastien SUZANNE <jssuzanne@anybox.fr>
# =
# This file is a part of anybus
# =
# anybus is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License v3 or later
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# =
# anybus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License v3 or later for more details.
# =
# You should have received a copy of the GNU Affero General Public License
# v3 or later along with this program.
# If not, see <http://www.gnu.org/licenses/>.
# =
#==============================================================================
{
'name': 'View 7.0 for fields selection',
'version': '0.2',
'category': 'Anybus/Views/7.0',
'description': """
View 6.1 for fields selection
""",
'author': 'Jean-Sebastien SUZANNE',
'website': 'http://anybox.fr',
'images': [],
'depends': [
'base',
'anybus_fields_selection',
],
'init_xml': [
],
'update_xml': [
'view/fields_selection.xml',
],
'demo_xml': [
],
'installable': True,
'application': False,
'auto_install': False,
'license': 'AGPL-3',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account
#
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment