diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fc9613 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/odoo/ diff --git a/addons/ospp_base/__init__.py b/addons/ospp_base/__init__.py new file mode 100644 index 0000000..511a0ca --- /dev/null +++ b/addons/ospp_base/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import controllers +from . import models \ No newline at end of file diff --git a/addons/ospp_base/__manifest__.py b/addons/ospp_base/__manifest__.py new file mode 100644 index 0000000..b98f768 --- /dev/null +++ b/addons/ospp_base/__manifest__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +{ + 'name': "OSPP BASE", + + 'summary': """ + OSPP BASE""", + + 'description': """ + OSPP BASE + """, + + 'author': "Zhiguo Yuan", + 'website': "https://www.newbizpaas.cn", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/16.0/odoo/addons/base/data/ir_module_category_data.xml + # for the full list + 'category': 'Website/eLearning', + 'version': '0.1', + + # any module necessary for this one to work correctly + 'depends': ['base', 'website_slides'], + + # always loaded + 'data': [ + # 'security/ir.model.access.csv', + 'views/views.xml', + 'views/templates.xml', + ], + # only loaded in demonstration mode + 'demo': [ + 'demo/demo.xml', + ], +} diff --git a/addons/ospp_base/controllers/__init__.py b/addons/ospp_base/controllers/__init__.py new file mode 100644 index 0000000..457bae2 --- /dev/null +++ b/addons/ospp_base/controllers/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import controllers \ No newline at end of file diff --git a/addons/ospp_base/controllers/controllers.py b/addons/ospp_base/controllers/controllers.py new file mode 100644 index 0000000..31e2ad1 --- /dev/null +++ b/addons/ospp_base/controllers/controllers.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# from odoo import http + + +# class OsppBase(http.Controller): +# @http.route('/ospp_base/ospp_base', auth='public') +# def index(self, **kw): +# return "Hello, world" + +# @http.route('/ospp_base/ospp_base/objects', auth='public') +# def list(self, **kw): +# return http.request.render('ospp_base.listing', { +# 'root': '/ospp_base/ospp_base', +# 'objects': http.request.env['ospp_base.ospp_base'].search([]), +# }) + +# @http.route('/ospp_base/ospp_base/objects/', auth='public') +# def object(self, obj, **kw): +# return http.request.render('ospp_base.object', { +# 'object': obj +# }) diff --git a/addons/ospp_base/demo/demo.xml b/addons/ospp_base/demo/demo.xml new file mode 100644 index 0000000..3ddd288 --- /dev/null +++ b/addons/ospp_base/demo/demo.xml @@ -0,0 +1,30 @@ + + + + + \ No newline at end of file diff --git a/addons/ospp_base/models/__init__.py b/addons/ospp_base/models/__init__.py new file mode 100644 index 0000000..5305644 --- /dev/null +++ b/addons/ospp_base/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models \ No newline at end of file diff --git a/addons/ospp_base/models/models.py b/addons/ospp_base/models/models.py new file mode 100644 index 0000000..83fe09a --- /dev/null +++ b/addons/ospp_base/models/models.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api + + +class OSPPInstance(models.Model): + _name = 'ospp.instance' + _description = 'OSPP Instance' + + name = fields.Char("Name") + code = fields.Char("Code") + type = fields.Selection([('saas', 'SAAS'), ('paas', 'PAAS')], required=True, string="Type") + stack = fields.Selection([('docker', 'Docker'), ('k8s', 'K8S'), ('odoo', 'ODOO')], required=True, string="Stack") + management_api = fields.Char('Management Api', required=True) + management_key = fields.Char('Management Key') + management_secret = fields.Char('Management Secret') + service_base_host = fields.Char('Service Base Host') + service_scheme = fields.Selection( + [('http', 'HTTP'), ('https', 'HTTPS'), ('ws', 'WS'), ('wss', 'WSS')], + required=True, string="Service Scheme") + dockerfile = fields.Text("Dockerfile") + active = fields.Boolean('Active', default=True) diff --git a/addons/ospp_base/security/ir.model.access.csv b/addons/ospp_base/security/ir.model.access.csv new file mode 100644 index 0000000..a598b32 --- /dev/null +++ b/addons/ospp_base/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_ospp_base_ospp_base,ospp_base.ospp_base,model_ospp_base_ospp_base,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/addons/ospp_base/views/templates.xml b/addons/ospp_base/views/templates.xml new file mode 100644 index 0000000..cea6b39 --- /dev/null +++ b/addons/ospp_base/views/templates.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/addons/ospp_base/views/views.xml b/addons/ospp_base/views/views.xml new file mode 100644 index 0000000..601d12c --- /dev/null +++ b/addons/ospp_base/views/views.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/addons/ospp_slide/__init__.py b/addons/ospp_slide/__init__.py new file mode 100644 index 0000000..511a0ca --- /dev/null +++ b/addons/ospp_slide/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import controllers +from . import models \ No newline at end of file diff --git a/addons/ospp_slide/__manifest__.py b/addons/ospp_slide/__manifest__.py new file mode 100644 index 0000000..e283853 --- /dev/null +++ b/addons/ospp_slide/__manifest__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +{ + 'name': "OSPP SLIDE", + + 'summary': """ + OSPP SLIDE""", + + 'description': """ + OSPP SLIDE + """, + + 'author': "Zhiguo Yuan", + 'website': "https://www.newbizpaas.cn", + + # Categories can be used to filter modules in modules listing + # Check https://github.com/odoo/odoo/blob/16.0/odoo/addons/base/data/ir_module_category_data.xml + # for the full list + 'category': 'Website/eLearning', + 'version': '0.1', + + # any module necessary for this one to work correctly + 'depends': ['ospp_base'], + + # always loaded + 'data': [ + # 'security/ir.model.access.csv', + 'views/views.xml', + 'views/templates.xml', + ], + # only loaded in demonstration mode + 'demo': [ + 'demo/demo.xml', + ], +} diff --git a/addons/ospp_slide/controllers/__init__.py b/addons/ospp_slide/controllers/__init__.py new file mode 100644 index 0000000..457bae2 --- /dev/null +++ b/addons/ospp_slide/controllers/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import controllers \ No newline at end of file diff --git a/addons/ospp_slide/controllers/controllers.py b/addons/ospp_slide/controllers/controllers.py new file mode 100644 index 0000000..8e421a4 --- /dev/null +++ b/addons/ospp_slide/controllers/controllers.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# from odoo import http + + +# class OsppSlide(http.Controller): +# @http.route('/ospp_slide/ospp_slide', auth='public') +# def index(self, **kw): +# return "Hello, world" + +# @http.route('/ospp_slide/ospp_slide/objects', auth='public') +# def list(self, **kw): +# return http.request.render('ospp_slide.listing', { +# 'root': '/ospp_slide/ospp_slide', +# 'objects': http.request.env['ospp_slide.ospp_slide'].search([]), +# }) + +# @http.route('/ospp_slide/ospp_slide/objects/', auth='public') +# def object(self, obj, **kw): +# return http.request.render('ospp_slide.object', { +# 'object': obj +# }) diff --git a/addons/ospp_slide/demo/demo.xml b/addons/ospp_slide/demo/demo.xml new file mode 100644 index 0000000..c43106a --- /dev/null +++ b/addons/ospp_slide/demo/demo.xml @@ -0,0 +1,30 @@ + + + + + \ No newline at end of file diff --git a/addons/ospp_slide/models/__init__.py b/addons/ospp_slide/models/__init__.py new file mode 100644 index 0000000..5305644 --- /dev/null +++ b/addons/ospp_slide/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models \ No newline at end of file diff --git a/addons/ospp_slide/models/models.py b/addons/ospp_slide/models/models.py new file mode 100644 index 0000000..01a1f55 --- /dev/null +++ b/addons/ospp_slide/models/models.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api, _ + + +class SlideChannel(models.Model): + _inherit = 'slide.channel' + + code = fields.Char('Code', required=True, copy=False, readonly=True, default=lambda self: _('New')) + instance_arrangement = fields.Selection( + [('share', 'Share'), ('exclude', 'Exclude'), ('both', 'Both'), ('no_need', 'No Need')], + string="Instance Arrangement") + share_instance_count = fields.Integer('Shared Instance Count') + instance_base = fields.Many2one('ospp.instance', string="Instance Base") + instance_ids = fields.One2many('channel.instance', 'channel_id', string="Instances") + + def name_get(self): + # Prefetch the fields used by the `name_get`, so `browse` doesn't fetch other fields + self.browse(self.ids).read(['name', 'code']) + return [(channel.id, '%s%s' % (channel.code and '[%s] ' % channel.code or '', channel.name)) + for channel in self] + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if 'company_id' in vals: + self = self.with_company(vals['company_id']) + if vals.get('name', _("New")) == _("New"): + seq_date = None + vals['name'] = self.env['ir.sequence'].next_by_code('slide.channel', sequence_date=seq_date) or _("New") + + return super().create(vals_list) + + +class ChannelInstance(models.Model): + _name = "channel.instance" + _inherit = ['mail.thread', 'mail.activity.mixin', 'image.mixin'] + _description = "Channel Instance" + + channel_id = fields.Many2one('slide.channel', required=True, string="Channel") + instance_id = fields.Many2one('ospp.instance', required=True, string="Instance") + name = fields.Char('Name', required=True) + code = fields.Char('Code', required=True, copy=False, readonly=True, default=lambda self: _('New')) + service_name = fields.Char('Service Name', required=True) + service_url = fields.Char('Service URL', required=True) + user_scope = fields.Many2many('slide.channel.partner', string="User Scope") + active = fields.Boolean('Active', default=True) + +# class ospp_slide(models.Model): +# _name = 'ospp_slide.ospp_slide' +# _description = 'ospp_slide.ospp_slide' + +# name = fields.Char() +# value = fields.Integer() +# value2 = fields.Float(compute="_value_pc", store=True) +# description = fields.Text() +# +# @api.depends('value') +# def _value_pc(self): +# for record in self: +# record.value2 = float(record.value) / 100 diff --git a/addons/ospp_slide/security/ir.model.access.csv b/addons/ospp_slide/security/ir.model.access.csv new file mode 100644 index 0000000..bb1a882 --- /dev/null +++ b/addons/ospp_slide/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_ospp_slide_ospp_slide,ospp_slide.ospp_slide,model_ospp_slide_ospp_slide,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/addons/ospp_slide/views/templates.xml b/addons/ospp_slide/views/templates.xml new file mode 100644 index 0000000..cea6b39 --- /dev/null +++ b/addons/ospp_slide/views/templates.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/addons/ospp_slide/views/views.xml b/addons/ospp_slide/views/views.xml new file mode 100644 index 0000000..499f5ad --- /dev/null +++ b/addons/ospp_slide/views/views.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file