Commit a5d8c3e1 authored by jssuzanne's avatar jssuzanne
Browse files

rename anybus.connection by anybus.profile

--HG--
branch : 8.0
parent 1915995b2cce
# flake8: noqa
import connection
import profile
import message
import ping
......@@ -40,7 +40,7 @@
'security/ir.model.access.csv',
'view/template.xml',
'view/menu.xml',
'view/connection.xml',
'view/profile.xml',
'view/message.xml',
'view/ping.xml',
],
......
# -*- coding: utf-8 -*-
from openerp import models, fields, api
from .connection import MessageStatus
from .profile import MessageStatus
from base64 import b64decode
from openerp.tools import config
import pika
......@@ -100,7 +100,7 @@ class AnybusMessage(models.Model):
self.write({'error': 'No profile found in configuration'})
return False
connection = self.env['anybus.connection'].search(
connection = self.env['anybus.profile'].search(
[('name', '=', profile)])
if not connection:
self.write({'error': 'No profile found in the connections'})
......
......@@ -14,7 +14,7 @@ class AnyBusPublishPing(models.TransientModel):
this.publish()
def publish(self):
self.env['anybus.connection'].publish(
self.env['anybus.profile'].publish(
self.exchange, self.routing_key,
dumps({
'exchange': self.exchange,
......
......@@ -8,13 +8,13 @@ from .schema import MessageStatus, anybus_schema_validation, PingSchema
logger = getLogger(__name__)
class anybusConnection(models.Model):
class AnyBusProfile(models.Model):
"""
Class used to establish the connection between your ERP and server
RabbitMQ
"""
_name = 'anybus.connection'
_description = 'anybus connection'
_name = 'anybus.profile'
_description = 'anybus profile'
name = fields.Char('Profil', required=True)
url = fields.Char(
......@@ -35,12 +35,10 @@ class anybusConnection(models.Model):
),
]
broker_connection = None
def get_consumers(self):
# (queue name, model, method name)
return [
('erp_ping', self._name, 'ping'),
('erp_%s_ping' % self.env.cr.dbname, self._name, 'ping'),
]
@anybus_schema_validation(PingSchema())
......
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"acc_anybus_connection","Connection","model_anybus_connection","anybus.groups_anybus",1,1,1,1
"acc_anybus_profile","Connection","model_anybus_profile","anybus.groups_anybus",1,1,1,1
"acc_anybus_message","Message","model_anybus_message","anybus.groups_anybus",1,1,1,1
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_anybus_connection_tree" model="ir.ui.view">
<field name="name">anybus.connection.tree</field>
<field name="model">anybus.connection</field>
<record id="view_anybus_profile_tree" model="ir.ui.view">
<field name="name">anybus.profile.tree</field>
<field name="model">anybus.profile</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<tree
string="Connections"
string="Profiles"
colors="red:state == 'disconnected';green:state == 'connected'"
editable="bottom"
>
......@@ -17,37 +17,37 @@
</tree>
</field>
</record>
<record id="view_anybus_connection_search" model="ir.ui.view">
<field name="name">anybus.connection.search</field>
<field name="model">anybus.connection</field>
<record id="view_anybus_profile_search" model="ir.ui.view">
<field name="name">anybus.profile.search</field>
<field name="model">anybus.profile</field>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<search string="Connections">
<search string="Profiles">
<field name="name"/>
<field name="url"/>
<field name="state"/>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="act_open_anybus_connection_view">
<field name="name">Connections</field>
<record model="ir.actions.act_window" id="act_open_anybus_profile_view">
<field name="name">Profiles</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">anybus.connection</field>
<field name="res_model">anybus.profile</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="search_view_id" ref="view_anybus_connection_search"/>
<field name="search_view_id" ref="view_anybus_profile_search"/>
<field name="domain">[]</field>
<field name="context">{}</field>
</record>
<record model="ir.actions.act_window.view" id="act_open_anybus_connection_view_tree">
<field name="act_window_id" ref="act_open_anybus_connection_view"/>
<record model="ir.actions.act_window.view" id="act_open_anybus_profile_view_tree">
<field name="act_window_id" ref="act_open_anybus_profile_view"/>
<field name="sequence" eval="10"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_anybus_connection_tree"/>
<field name="view_id" ref="view_anybus_profile_tree"/>
</record>
<menuitem id="menu_anybus_connection"
<menuitem id="menu_anybus_profile"
parent="menu_anybus_general"
sequence="10"
action="act_open_anybus_connection_view"/>
action="act_open_anybus_profile_view"/>
</data>
</openerp>
from pika import SelectConnection, URLParameters
from openerp.addons.anybus.connection import MessageStatus
from openerp.addons.anybus.profile import MessageStatus
from base64 import b64encode
import logging
......@@ -18,7 +18,7 @@ class Consumer:
self.odoo_connection = None
def get_url(self):
connection = self.session.env['anybus.connection'].search(
connection = self.session.env['anybus.profile'].search(
[('name', '=', self.profile)])
if connection:
self.odoo_connection = connection
......
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