Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions saas_domains/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
15 changes: 15 additions & 0 deletions saas_domains/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
{
'name': 'SaaS Sysadmin DNS Manager',
'version': '10.0.1.0.0',
'author': 'Cristian Salamea',
'license': 'LGPL-3',
'category': 'SaaS',
"support": "[email protected]",
'website': 'https://it-projects.info',
'depends': ['saas_sysadmin'],
'data': [
'views/domain_views.xml'
],
'installable': True,
}
3 changes: 3 additions & 0 deletions saas_domains/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
70 changes: 70 additions & 0 deletions saas_domains/models/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-

from odoo import api, models, fields


class SaasDomainZone(models.Model):
_name = 'saas_sysadmin.domain.zone'

name = fields.Char('Domain', required=True)
soa_email = fields.Char('SOA Email', required=True)
a_record_ids = fields.One2many('saas_sysadmin.domain.record', 'zone_id', 'A/AAA Records')
dns_provider = fields.Selection(
[
('route53', 'AWS Route53'),
('linode', 'Linode')
],
string='DNS Provider',
required=True,
default='route53'
)

@api.multi
def action_pull_records(self):
raise NotImplementedError

@api.multi
def action_push_records(self):
raise NotImplementedError


class SaasDomainRecord(models.Model):
_name = 'saas_sysadmin.domain.record'

hostname = fields.Char('Hostname', required=True)
ttl_value = fields.Char('TTL')
type = fields.Selection(
[
('ns', 'NS'),
('mx', 'MX'),
('a', 'A/AAA'),
('cname', 'CNAME'),
('txt', 'TXT')
],
required=True,
default='a'
)
ip_address = fields.Char('IP Address')
zone_id = fields.Many2one(comodel_name='saas_sysadmin.domain.zone', string='Zone', ondelete='cascade')
auto_sync = fields.Boolean('Auto Sync with Provider (CRUD)')

@api.multi
def action_sync(self, method='POST'):
"""
based on method will call API
"""
raise NotImplementedError

@api.model
def create(self, values):
record = super(SaasDomainRecord, self).create(values)
if record.auto_sync:
self.action_sync()
return record

@api.multi
def unlink(self):
for obj in self:
if obj.auto_sync:
self.action_sync('DELETE')
return True
56 changes: 56 additions & 0 deletions saas_domains/views/domain_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<odoo>
<data>

<menuitem id="menu_saas_domains" parent="saas_portal.menu_base_saas" name="Domains"/>

<record id="view_domain_zone_tree" model="ir.ui.view">
<field name="name">view.domain.zone.tree</field>
<field name="model">saas_sysadmin.domain.zone</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="soa_email"/>
<field name="dns_provider"/>
</tree>
</field>
</record>

<record id="view_domain_zone_form" model="ir.ui.view">
<field name="name">view.domain.zone.form</field>
<field name="model">saas_sysadmin.domain.zone</field>
<field name="arch" type="xml">
<form>
<header>
<button name="action_pull_records" string="Pull Records" type="object" icon="fa-cog"/>
</header>
<sheet>
<group>
<field name="name"/>
<field name="soa_email"/>
<field name="dns_provider"/>
</group>
<group string="A/AAA Records">
<field name="a_record_ids" nolabel="1">
<tree editable="bottom">
<field name="hostname" string="Hostname"/>
<field name="ip_address"/>
<field name="ttl_value"/>
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>

<record id="action_domain_zone" model="ir.actions.act_window">
<field name="name">Domain Zone</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">saas_sysadmin.domain.zone</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem action="action_domain_zone" id="menu_domain_zone" parent="menu_saas_domains" sequence="10"/>
</data>
</odoo>