Skip to content

Commit

Permalink
Merge e6cded5 into 1f327a8
Browse files Browse the repository at this point in the history
  • Loading branch information
osi-scampbell committed Sep 19, 2019
2 parents 1f327a8 + e6cded5 commit 9f6f0a4
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
4 changes: 4 additions & 0 deletions connector_equipment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
22 changes: 22 additions & 0 deletions connector_equipment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Connector Equipment',
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'summary': 'Connect Equipment to Outside API',
'author': "Open Source Integrators",
'depends': ['maintenance'],
'data': [
'views/maintenance_equipment.xml',
],
'installable': True,
'auto_install': True,
'development_status': 'Beta',
'maintainers': [
'wolfhall',
'max3903',
'osi-scampbell',
],
}
5 changes: 5 additions & 0 deletions connector_equipment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from . import maintenance_equipment
58 changes: 58 additions & 0 deletions connector_equipment/models/maintenance_equipment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class MaintenanceEquipment(models.Model):
_inherit = 'maintenance.equipment'
_description = 'Maintenance Equipment'

managed = fields.Boolean('Can be managed')
host = fields.Char('Host')
port = fields.Char('Port')
user = fields.Char('User')
password = fields.Char('Password')
protocol = fields.Selection([('http_json', 'HTTP/JSON'),
('rest', 'REST')], 'Protocol')

def update_config(self):
return True

def _connect(self, function, serviceprofiles=None):
if function == 'update_config':
self.update_config()
elif function == 'add_service':
if serviceprofiles:
for sp_id in serviceprofiles:
self.add_service(sp_id)
elif function == 'update_service':
if serviceprofiles:
for sp_id in serviceprofiles:
self.update_service(sp_id)
elif function == 'activate_service':
if serviceprofiles:
for sp_id in serviceprofiles:
self.activate_service(sp_id)
elif function == 'suspend_service':
if serviceprofiles:
for sp_id in serviceprofiles:
self.suspend_service(sp_id)
elif function == 'remove_service':
if serviceprofiles:
for sp_id in serviceprofiles:
self.remove_service(sp_id)

@api.multi
def create(self, vals):
res = super().create(vals)
if self.managed:
self._connect('update_config')
return res

@api.multi
def write(self, vals):
res = super().write(vals)
if self.managed:
self._connect('update_config')
return res
30 changes: 30 additions & 0 deletions connector_equipment/views/maintenance_equipment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- Copyright 2019 Open Source Integrators
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -->

<odoo>
<record id="maintenance_equipment_connector_page" model="ir.ui.view">
<field name="name">maintenance.equipment.connector.page</field>
<field name="model">maintenance.equipment</field>
<field name="inherit_id" ref="maintenance.hr_equipment_view_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[3]" position="after">
<page string="Connector">
<h2>API Information</h2>
<group>
<group>
<field name="host"/>
<field name="port"/>
<field name="user"/>
<field name="password" widget="password"/>
<field name="protocol"/>
</group>
</group>
</page>
</xpath>
<field name="category_id" position="before">
<field name="managed"/>
</field>
</field>
</record>

</odoo>

0 comments on commit 9f6f0a4

Please sign in to comment.