Commit a13811da authored by jssuzanne's avatar jssuzanne
Browse files

Remove useless module

--HG--
branch : 8.0
parent d9be8a65e07b
# -*- coding: utf-8 -*-
from odoo import models, fields
import socket
from tools.translate import _
class anybusConnection(models.Model):
......@@ -13,14 +11,10 @@ class anybusConnection(models.Model):
_description = 'anybus connection'
name = fields.Char('Profil', required=True)
# type = fields.Selection(
# (('url', 'URL'), ('parameter', 'Config parameter')), default='url',
# help='Define if the connection parameter come from URL or another'
# )
url = field.Char(
url = fields.Char(
size=255, required=True,
help='Define the connection URI for the AMQP broker (ex: RabbitMQ)'
default='amqp://guest:guest@localhost:5672/%2F',
help='Define the connection URI for the AMQP broker (ex: RabbitMQ)',
default='amqp://guest:guest@localhost:5672/%2F'
)
state = fields.Selection(
(('disconnected', 'Disconnected'), ('connected', 'Connected')),
......@@ -38,22 +32,10 @@ class anybusConnection(models.Model):
This function searches all exchanges, queues and binding,
and declare it in rabbitmq
"""
exchange_obj = self.pool.get('anybus.entity.exchange')
exchange_ids = exchange_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
exchange_obj.action_declare(cr, uid, exchange_ids, context=context)
queue_obj = self.pool.get('anybus.entity.queue')
queue_ids = queue_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
queue_obj.action_declare(cr, uid, queue_ids, context=context)
return {}
# TODO
def action_purge_all(self, cr, uid, ids, context=None):
def action_purge_all(self):
"""
Purge all queues which are at the draft state
Purge all queues
"""
queue_obj = self.pool.get('anybus.entity.queue')
queue_ids = queue_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
queue_obj.action_purge(cr, uid, queue_ids, context=context)
return {}
# TODO
# -*- coding: utf-8 -*-
from osv import osv, fields
from kombu import Connection
import socket
from tools.translate import _
class anybusConnection(osv.Model):
"""
Class used to establish the connection between your ERP and server RabbitMQ
.. Note::
The BrokerConnection class supports additional keyword arguments,
these are: hostname: Default host name if not provided in the URL.
userid: Default user name if not provided in the URL. password: Default password
if not provided in the URL. virtual_host: Default virtual host if not provided in the
URL. port: Default port if not provided in the URL. transport: Default transport if
not provided in the URL. Can be a string specifying the path to the class.
(e.g. kombu.transport.pyamqplib. Transport), or one of the aliases: amqplib, pika,
redis, memory, and so on. ssl: Use SSL to connect to the server. Default is False.
Only supported by the amqp transport. insist: Insist on connecting to a server. In a
configuration with multiple load-sharing servers, the insist option tells the server
that the client is insisting on a connection to the specified server. Default is
False. Only supported by the amqp and pika transports, and not by AMQP 0-9-1.
connect_timeout: Timeout in seconds for connecting to the server. May not be
supported by the specified transport. transport_options: A dict of additional
connection arguments to pass to alternate kombu channel implementations. Consult the
transport
documentation for available options.
"""
_name = 'anybus.connection'
_description = 'anybus connection'
_columns = {
'name': fields.char('Name', size=64, required=True),
'uri': fields.char(
'URI', size=255, required=True, help='Define the connection URI '
'for the AMQP broker (ex: RabbitMQ)'),
'state': fields.selection(
[('draft', 'Draft'), ('declared', 'Declared')], 'State',
readonly=True, help='Define the state of the connection'),
'exchange_ids': fields.one2many(
'anybus.entity.exchange', 'connection_id', 'Exchanges',
readonly=True),
'queue_ids': fields.one2many('anybus.entity.queue', 'connection_id',
'Queues', readonly=True),
}
_defaults = {
'uri': lambda *a: 'amqp://guest:guest@localhost:5672//%(dbname)s',
'state': lambda *a: 'draft',
}
def _get_uri(self, cr, uid, connection, context=None):
"""
return the uri of the connexion
"""
return connection.uri % {'dbname': cr.dbname}
def action_declare(self, cr, uid, ids, context=None):
"""
Function to declare a connection. When a connection is declared,
then you are connected to the RabbitMQ server.
"""
for connection in self.browse(cr, uid, ids, context=context):
try:
uri = self._get_uri(cr, uid, connection, context=context)
conn = Connection(uri)
conn.connect()
conn.close()
conn.release()
connection.write({'state': 'declared'})
except socket.error, e:
raise osv.except_osv(
_('Anybus Connection error'), e.args[1].decode('utf-8'))
except IOError, e:
error = "No vhost found for %r" % uri
raise osv.except_osv(_('Anybus Connection error'),
_(error))
return {}
def action_redraft(self, cr, uid, ids, context=None):
"""
This function searches all exchanges and queues that are reported
and changes their state in ``draft``
"""
exchange_obj = self.pool.get('anybus.entity.exchange')
exchange_ids = exchange_obj.search(
cr, uid, [('state', '=', 'declared')], context=context)
exchange_obj.action_redraft(cr, uid, exchange_ids, context=context)
queue_obj = self.pool.get('anybus.entity.queue')
queue_ids = queue_obj.search(
cr, uid, [('state', '=', 'declared')], context=context)
queue_obj.action_redraft(cr, uid, queue_ids, context=context)
self.write(cr, uid, ids, {'state': 'draft'}, context=context)
return {}
def action_declare_all(self, cr, uid, ids, context=None):
"""
This function searches all exchanges and queues which are at the draft state
and ``declare`` it.
"""
exchange_obj = self.pool.get('anybus.entity.exchange')
exchange_ids = exchange_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
exchange_obj.action_declare(cr, uid, exchange_ids, context=context)
queue_obj = self.pool.get('anybus.entity.queue')
queue_ids = queue_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
queue_obj.action_declare(cr, uid, queue_ids, context=context)
return {}
def action_purge_all(self, cr, uid, ids, context=None):
"""
Purge all queues which are at the draft state
"""
queue_obj = self.pool.get('anybus.entity.queue')
queue_ids = queue_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
queue_obj.action_purge(cr, uid, queue_ids, context=context)
return {}
def get_actions(self, cr, uid, ids, model, context=None):
"""
"""
model_ids = self.pool.get(model).search(cr, uid, [], context=context)
res = {}
for id in ids:
res[id] = model_ids
return res
## vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
<record id="anybus_connection_demo" model="anybus.connection">
<field name="name">Server local</field>
</record>
<record id="anybus_entity_exchange_demo" model="anybus.entity.exchange">
<field name="connection_id" ref="anybus_connection_demo"/>
<field name="name">demo_%(dbname)s_exchange</field>
</record>
<record id="anybus_entity_queue_demo" model="anybus.entity.queue">
<field name="connection_id" ref="anybus_connection_demo"/>
<field name="name">demo_%(dbname)s_queue</field>
</record>
<record id="anybus_binding_demo" model="anybus.binding">
<field name="exchange_id" ref="anybus_entity_exchange_demo"/>
<field name="queue_id" ref="anybus_entity_queue_demo"/>
</record>
</data>
</openerp>
# -*- coding: utf-8 -*-
#flake8: noqa
import fields_selection
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
#!/usr/bin/env python
{
'name': 'Fields selection',
'version': '0.3',
'category': 'Anybus/Utility',
'description': """
Add tree of fields to select one export
""",
'author': 'Jean-Sebastien SUZANNE',
'website': 'http://anybox.fr',
'images': [],
'depends': [
'base',
],
'update_xml': [
'security/ir.model.access.csv',
'view/fields_selection.xml',
],
'installable': True,
'application': False,
'auto_install': False,
'license': 'AGPL-3',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# -*- coding: utf-8 -*-
from osv import osv, fields
class AnybusFieldsSelection(osv.Model):
_name = 'anybus.fields.selection'
_description = 'Anybus fields selection'
_rec_name = "sub_field_id"
_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),
'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'),
'add_db_id': fields.boolean('DB ID'),
'add_xml_id': fields.boolean('XML ID'),
}
_defaults = {
'add_db_id': lambda *a: False,
'add_xml_id': lambda *a: False,
}
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)
value = {'ttype': field['ttype']}
if field['relation']:
value['relation_id'] = self.pool.get('ir.model').search(
cr, uid, [('model', '=', field['relation'])],
context=context)[0]
res['value'] = value
return res
def __get_fields_name(self, cr, uid, this, parent='', context=None):
result = {}
field_name = parent + this.sub_field_id.name
field_description = this.sub_field_id.field_description
if this.ttype in ('one2many', 'many2many', 'many2one'):
if this.add_db_id:
result.update({field_name + '/.id': field_description})
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))
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))
return result
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account
#
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"acc_anybus_fields_selection","Fields selection","model_anybus_fields_selection","",1,1,1,1
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_anybus_fields_selection_tree" model="ir.ui.view">
<field name="name">anybus.fields.selection.tree</field>
<field name="model">anybus.fields.selection</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<tree string="Fields selection">
<field name="sub_field_id"/>
</tree>
</field>
</record>
<record id="view_anybus_fields_selection_form" model="ir.ui.view">
<field name="name">anybus.fields.selection.form</field>
<field name="model">anybus.fields.selection</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<form string="Fields selection" version="7.0">
<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)"/>
<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'))]}"/>
</group>
</form>
</field>
</record>
</data>
</openerp>
#!/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/>.
# =
#==============================================================================
import process
# 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': 'Consumer function',
'version': '0.2',
'category': 'Anybus/Addons/Incoming treatment',
'description': """
Fonction treatment for the consumer
""",
'author': 'Jean-Sebastien SUZANNE',
'website': 'http://anybox.fr',
'images': [],
'depends': [
'base',
'anybus_consumer',
],
'init_xml': [
],
'update_xml': [
'security/ir.model.access.csv',
'view/process.xml',
],
'demo_xml': [
'demo/demo.xml',
],
'installable': True,
'application': False,
'auto_install': False,
'license': 'AGPL-3',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
<record id="anybus_consumer_process_function" model="anybus.consumer.process.function">
<field name="name">Function 1</field>
<field name="function">print message.properties</field>
</record>
</data>
</openerp>
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account
#
# -*- coding: utf-8 -*-
from osv import osv, fields
import base64
class AnybusConsumerProcessFonction(osv.Model):
_name = 'anybus.consumer.process.function'
_description = 'process fonction for consumer'
_inherits = {'anybus.consumer.process': 'process_id'}
_inherit = 'abstract.anybus.process'
_columns = {
'process_id': fields.many2one('anybus.consumer.process',
'process', required=True, ondelete="cascade"),
'function': fields.text('Function'),
}
_defaults = {
'function': lambda *a: """# self => current self
# cr => current cursor
# uid => current user
# message_obj => regisry to the message
# message_id => id of the message
# message => browse on the model with model_id
# context => the context
# base64 => base64 librairy """
}
def _process_process(self, cr, uid, id, model, model_ids, context=None):
this = self.browse(cr, uid, id, context=context)
obj = self.pool.get(model)
globals_dict = {}
method_local = {
'message_obj': obj,
'self': self,
'cr': cr,
'uid': uid,
'message': obj.browse(cr, uid, model_ids[0], context=context),
'message_id': model_ids[0],
'context': context,
'base64': base64,
}
eval(compile(this.function, "", "exec"), globals_dict, method_local)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"acc_anybus_consumer_process_function","Consumer function process","model_anybus_consumer_process_function","",1,1,1,1
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
#==============================================================================
# =
# 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/.
# =
#==============================================================================
<record id="view_process_function_tree" model="ir.ui.view">
<field name="name">anybus.consumer.process.function.tree</field>
<field name="model">anybus.consumer.process.function</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<tree string="Consumer process functions" fonts="bold:isdefault==True">
<field name="name"/>
<field name="isdefault"/>
</tree>
</field>
</record>
<record id="view_process_function_form" model="ir.ui.view">
<field name="name">anybus.consumer.process.function.form</field>
<field name="model">anybus.consumer.process.function</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<form string="Consumer process functions" version="7.0">
<sheet>
<group colspan="4">
<field name="name"/>
</group>
<field name="function" nolabel="1" colspan="4"/>
</sheet>
</form>
</field>
</record>
<record id="view_process_function_search" model="ir.ui.view">
<field name="name">anybus.consumer.process.function.search</field>
<field name="model">anybus.consumer.process.function</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<search string="Consumer process functions">
<field name="name"/>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="act_open_process_function_view">
<field name="name">Consumer process functions</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">anybus.consumer.process.function</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_process_function_search"/>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>
<record model="ir.actions.act_window.view" id="act_open_process_function_view_form">
<field name="act_window_id" ref="act_open_process_function_view"/>
<field name="sequence" eval="20"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_process_function_form"/>
</record>
<record model="ir.actions.act_window.view" id="act_open_process_function_view_tree">
<field name="act_window_id" ref="act_open_process_function_view"/>
<field name="sequence" eval="10"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_process_function_tree"/>
</record>
<menuitem id="menu_process_function"
parent="anybus_consumer.menu_anybus_consumer_process_root"
sequence="20"
action="act_open_process_function_view"/>
</data>
</openerp>
#!/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>