Commit a5d8c3e1 authored by jssuzanne's avatar jssuzanne
Browse files

rename anybus.connection by anybus.profile

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