-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |