diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a14f254 --- /dev/null +++ b/.gitignore @@ -0,0 +1,49 @@ +# sphinx build directories +_build/ + +# dotfiles +.* +!.gitignore +!.github +!.mailmap +# compiled python files +*.py[co] +__pycache__/ +# setup.py egg_info +*.egg-info +# emacs backup files +*~ +# hg stuff +*.orig +status +# odoo filestore +odoo/filestore +# maintenance migration scripts +odoo/addons/base/maintenance + +# generated for windows installer? +install/win32/*.bat +install/win32/meta.py + +# needed only when building for win32 +setup/win32/static/less/ +setup/win32/static/wkhtmltopdf/ +setup/win32/static/postgresql*.exe + +# js tooling +node_modules +jsconfig.json +tsconfig.json +package-lock.json +package.json +.husky + +# various virtualenv +/bin/ +/build/ +/dist/ +/include/ +/lib/ +/man/ +/share/ +/src/ diff --git a/proxmox/Readme.md b/proxmox/Readme.md new file mode 100644 index 0000000..d9887e4 --- /dev/null +++ b/proxmox/Readme.md @@ -0,0 +1,30 @@ +# Setup config in proxmox + +Downdload this project in connect node in proxmox and execute `./setup.sh` script. + +## Output + +```bash +Setup config in proxmox \n +Create group thorpe \n +Create user thorpe_access@pve +Add to thorpe groupe user thorpe_access@pve +Create and config api token +┌──────────────┬────────────────────────────────────────────────────────── +│ key │ value +╞══════════════╪══════════════════════════════════════════════════════════ +│ full-tokenid │ thorpe_access@pve!thorpe_api_token +├──────────────┼────────────────────────────────────────────────────────── +│ info │ {"comment":"Token to acess by thorpe integration","privse +├──────────────┼────────────────────────────────────────────────────────── +│ value │ 219cd33f-fc7a-4cb8-b94e-32d4a4df99de +└──────────────┴────────────────────────────────────────────────────────── +Add permitions to api token \n +Add permitions to vms +Add permitions to storage +Add permitions to nodes +Add permitions to group user \n +``` + +The config of api token is finish, copy `full-tokenid` to `Token` in thorpe-base and `value` to `Secret` in thorpe-base + diff --git a/proxmox/permitions.sh b/proxmox/permitions.sh new file mode 100755 index 0000000..8272cbf --- /dev/null +++ b/proxmox/permitions.sh @@ -0,0 +1,20 @@ +echo "Add permitions to api token \n" + +echo "Add permitions to vms" +pveum aclmod /vms -token thorpe_access@pve!thorpe_api_token -role Thorpe.instance + +echo "Add permitions to storage" +pveum aclmod /storage/local-lvm -token thorpe_access@pve!thorpe_api_token -role Thorpe.storage +pveum aclmod /storage/local -token thorpe_access@pve!thorpe_api_token -role Thorpe.storage +pveum aclmod /storage -token thorpe_access@pve!thorpe_api_token -role Thorpe.storage +pveum aclmod /storage -token thorpe_access@pve!thorpe_api_token -role Thorpe.template + +echo "Add permitions to nodes" +pveum aclmod /nodes -token thorpe_access@pve!thorpe_api_token -role Thorpe.nodes + + +echo "Add permitions to group user \n" +pveum aclmod /storage/local-lvm -group thorpe -role Thorpe.storage +pveum aclmod /storage/local -group thorpe -role Thorpe.storage + + diff --git a/proxmox/roles.sh b/proxmox/roles.sh new file mode 100755 index 0000000..a377b44 --- /dev/null +++ b/proxmox/roles.sh @@ -0,0 +1,15 @@ +# create Role to manager lxc and vms +# +pveum role add Thorpe.instance --privs "Datastore.Audit VM.Allocate VM.Audit VM.Config.CDROM VM.Config.Disk VM.Migrate VM.Monitor VM.PowerMgmt" + +# create Role to list nodes +# +pveum role add Thorpe.nodes --privs "Sys.Audit" + +# create Role to manger storage +# +pveum role add Thorpe.storage --privs "Datastore.Allocate Datastore.AllocateSpace Datastore.Audit VM.Audit" + +# create Role to list templates lxc and vms +# +pveum role add Thorpe.template --privs "VM.Audit" diff --git a/proxmox/setup.sh b/proxmox/setup.sh new file mode 100755 index 0000000..2dec485 --- /dev/null +++ b/proxmox/setup.sh @@ -0,0 +1,12 @@ + +# this setup thorpe config in proxmox +echo "Setup config in proxmox \n" + +./roles.sh + +./user.sh + +./token.sh + +./permitions.sh + diff --git a/proxmox/token.sh b/proxmox/token.sh new file mode 100755 index 0000000..d007712 --- /dev/null +++ b/proxmox/token.sh @@ -0,0 +1,2 @@ +echo "Create and config api token" +pveum user token add thorpe_access@pve thorpe_api_token -comment "Token to acess by thorpe integration" diff --git a/proxmox/user.sh b/proxmox/user.sh new file mode 100755 index 0000000..7d6ec80 --- /dev/null +++ b/proxmox/user.sh @@ -0,0 +1,9 @@ + +echo "Create group thorpe \n" +pveum groupadd thorpe -comment "Goup to manager thorpe access" + +echo "Create user thorpe_access@pve" +pveum useradd thorpe_access@pve -comment "User to thorpe config" + +echo "Add to thorpe groupe user thorpe_access@pve" +pveum usermod thorpe_access@pve -group thorpe diff --git a/roadmap.md b/roadmap.md new file mode 100644 index 0000000..f12f31c --- /dev/null +++ b/roadmap.md @@ -0,0 +1,50 @@ +MODULO PARA GERENCIAR O MENU E AS CONFIGURAÇÔES + + Nome: thorpe-base + Descrição: Adicionar 1 ou mais PVE Cluster nos Banco, configurar usuário e token de acesso ele irá usar as configurações de thorpe-products para criar thorpe-machines + +MODULO PARA GERENCIAR PRODUTOS PADRÃO + + Nome: thorpe-products + Descrição: Irá listar produtos base/template para poder adicionar no e-commerce com alguns valores padrões (Node para fazer o deployment, Rede Disponível, LXC ou VM | Número de CPUs(lxc) ou CPUS + Sockets(vm) + Discos + Imagens disponívels (Tkl-odoo, tkl-wordpres, tkl-debian, debin, ubuntu etc) + +MODULO PARA GERENCIAR MAQUINAS/CONTAINERS + + Nome: thorpe-machine + Descrição: Irá listar as maquinas já disponíveis e os usuários vinculados a elas, irá disponibilizar valores estáticos de status da maquina, nº de CPUs ativos atualmente, RAM Disponível e Uso de Disco + +MODULO PARA GERENCIAR PERMISSÕES DE ACESSO AS MAQUINAS + + Nome: thorpe-users + Descrição: irá vincular res.partners a faturas e thorpe-machines ativas + + +--------------------------------------------------------------- + +##thorpe-base## + MENU CONFIGURAÇÃO + + --PVE CLUSTER + ----PVE AUTH + ----PVE NODES + ----PVE MACHINES (vm ou lxc) + +##thorpe-machines## + +Estrutura: + type(lxc/vm): #Herado do thorpe-base + domain: #input do usuário na loja + cores: #input do usuário na loja + mem: #input do usuário na loja + disk: #input do usuário na loja + image: #input do usuário na loja + !owner: #herdado do res.partner/e-commerce-sale + +##thorpe-users one-to-many (Odoo nativo) + model(owner:machine) será equivalente a: + res.partner:thorpe.machine + +##thorpe-products + pve.node: + pve.network + pve.machine (lxc ou vm) diff --git a/sales-thorpe/__init__.py b/sales-thorpe/__init__.py deleted file mode 100644 index 511a0ca..0000000 --- a/sales-thorpe/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- - -from . import controllers -from . import models \ No newline at end of file diff --git a/sales-thorpe/controllers/controllers.py b/sales-thorpe/controllers/controllers.py deleted file mode 100644 index 9fadfb2..0000000 --- a/sales-thorpe/controllers/controllers.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# from odoo import http - - -# class Sales-thorpe(http.Controller): -# @http.route('/sales-thorpe/sales-thorpe', auth='public') -# def index(self, **kw): -# return "Hello, world" - -# @http.route('/sales-thorpe/sales-thorpe/objects', auth='public') -# def list(self, **kw): -# return http.request.render('sales-thorpe.listing', { -# 'root': '/sales-thorpe/sales-thorpe', -# 'objects': http.request.env['sales-thorpe.sales-thorpe'].search([]), -# }) - -# @http.route('/sales-thorpe/sales-thorpe/objects/', auth='public') -# def object(self, obj, **kw): -# return http.request.render('sales-thorpe.object', { -# 'object': obj -# }) diff --git a/thorpe_base/__init__.py b/thorpe_base/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/thorpe_base/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/thorpe_base/__manifest__.py b/thorpe_base/__manifest__.py new file mode 100644 index 0000000..a98c977 --- /dev/null +++ b/thorpe_base/__manifest__.py @@ -0,0 +1,27 @@ +{ + 'name': "Thorpe Base", + 'version': '1.0', + 'summary': "The base thorpe project for api connect to proxmox", + 'sequence': 10, + 'description': """ + Thorpe base + This module create configuration to api proxmox connect. + """, + 'author': 'Marcos Méndez & Enieber Cunha | pop.coop', + 'category': 'Applications', + 'license': 'AGPL-3', + 'depends': ['base', 'mail'], + 'data': [ + 'security/ir.model.access.csv', + 'views/thorpe_base.xml', + 'data/ir_cron_nodes.xml', + 'data/ir_cron_storages.xml', + 'views/thorpe_nodes.xml', + 'views/thorpe_storages.xml', + 'views/menu.xml', + ], + 'images': ['static/img/icon.png'], + 'installable': True, + 'application': True, + 'auto_install': False, +} diff --git a/thorpe_base/data/ir_cron_nodes.xml b/thorpe_base/data/ir_cron_nodes.xml new file mode 100644 index 0000000..d933687 --- /dev/null +++ b/thorpe_base/data/ir_cron_nodes.xml @@ -0,0 +1,15 @@ + + + + + Update Nodes PVE + + code + model.update_nodes() + 1 + hours + -1 + + + + diff --git a/thorpe_base/data/ir_cron_storages.xml b/thorpe_base/data/ir_cron_storages.xml new file mode 100644 index 0000000..5c2f4d1 --- /dev/null +++ b/thorpe_base/data/ir_cron_storages.xml @@ -0,0 +1,15 @@ + + + + + Atualizar Storages com dados do Node selecionado + + code + model.update_storages() + 1 + hours + -1 + + + + diff --git a/thorpe_base/models/__init__.py b/thorpe_base/models/__init__.py new file mode 100644 index 0000000..388cbf8 --- /dev/null +++ b/thorpe_base/models/__init__.py @@ -0,0 +1,5 @@ +from . import thorpe_base +from . import thorpe_base_node +from . import thorpe_base_storage +from . import update_nodes +from . import update_storages diff --git a/thorpe_base/models/thorpe_base.py b/thorpe_base/models/thorpe_base.py new file mode 100644 index 0000000..c07820f --- /dev/null +++ b/thorpe_base/models/thorpe_base.py @@ -0,0 +1,16 @@ +from odoo import _, api, fields, models + +class ThorpeBase(models.Model): + _name = 'thorpe.base' + _description = 'Infraestruct Orchestrator conection' + + #Model Fields + name = fields.Char(string="Name", required=True) + region = fields.Char(string="Region", required=True) + url = fields.Char(string="Url Api", required=True) + token = fields.Char(string="Token Api", required=True) + secret = fields.Char(string="Secret Token", required=True) + expiration = fields.Date(string="Expiration", required=True) + latitude = fields.Float(string="Latitude", required=True) + longitude = fields.Float(string="Longitude", required=True) + comments = fields.Text(string="Comments", required=False, translate=True) diff --git a/thorpe_base/models/thorpe_base_node.py b/thorpe_base/models/thorpe_base_node.py new file mode 100644 index 0000000..c8e77c6 --- /dev/null +++ b/thorpe_base/models/thorpe_base_node.py @@ -0,0 +1,10 @@ +from odoo import _, api, fields, models + +class ThorpeBaseNode(models.Model): + _name = 'thorpe.base.node' + _description = 'Nodes of pve selected' + + name = fields.Char(string="Name", required=True) + pve_id = fields.Many2one("thorpe.base", string="pve", required=True) + selected_to_sales = fields.Boolean(string="Active to Sales", required=True, default=False) + status = fields.Char(string="status", required=True) diff --git a/thorpe_base/models/thorpe_base_storage.py b/thorpe_base/models/thorpe_base_storage.py new file mode 100644 index 0000000..197654d --- /dev/null +++ b/thorpe_base/models/thorpe_base_storage.py @@ -0,0 +1,10 @@ +from odoo import _, api, fields, models + +class ThorpeBaseStorage(models.Model): + _name = 'thorpe.base.storage' + _description = 'Storage of node selected' + + name = fields.Char(string="Name", required=True) + node_id = fields.Many2one("thorpe.base.node", string="node", required=True) + selected_to_images = fields.Boolean(string="Active to use", default=False, required=True) + used_fraction = fields.Char(string="Fraction Used", required=True) diff --git a/thorpe_base/models/thorpe_request.py b/thorpe_base/models/thorpe_request.py new file mode 100644 index 0000000..4d8df15 --- /dev/null +++ b/thorpe_base/models/thorpe_request.py @@ -0,0 +1,77 @@ +import logging +import requests +import json +from dataclasses import dataclass, asdict + +_logger = logging.getLogger(__name__) + +class ThorpeRequest(): + _name = 'thorpe.request' + + def show_log(self, msg): + _logger.info("-----------------------------------------------------") + _logger.info(f"{msg}") + + def get_request(self, url, headers): + try: + self.show_log("Request GET") + self.show_log(url) + response = requests.get(url, headers=headers, verify=True) + return response + except Exception as e: + self.show_log(f"Error to GET request: {str(e)}") + + def post_request(self, url, headers, body): + try: + self.show_log("Request POST") + self.show_log(url) + self.show_log(body) + response = requests.post(url, headers=headers, data=body, verify=True) + except Exception as e: + self.show_log(f"Error to POST request: {str(e)}") + + def put_request(self, url, headers, body): + try: + self.show_log("Request PUT") + self.show_log(url) + self.show_log(body) + response = requests.put(url, headers=headers, json=body, verify=True) + except Exception as e: + self.show_log(f"Error to PUT request: {str(e)}") + + def delete_request(self, url, headers): + try: + self.show_log("Request DELETE") + self.show_log(url) + response = requests.delete(url, headers=headers, verify=True) + return response + except Exception as e: + self.show_log(f"Error to DELETE request: {str(e)}") + + + def make_request(self, pve, url_request, method, body=None): + _logger.info(f"PVE: {pve.name} -> {pve.url}") + base_url = pve.url + token_id = pve.token + token_secret = pve.secret + pve_api_token = f"{token_id}={token_secret}" + + # Cabeçalhos da solicitação + headers = { + 'Authorization': f'PVEAPIToken={pve_api_token}', + 'Content-Type': 'application/json' + } + url = f"{base_url}{url_request}" + + if method.upper() == 'GET': + return self.get_request(url, headers=headers) + elif method.upper() == 'POST': + return self.post_request(url, headers=headers, body=body) + elif method.upper() == 'PUT': + return self.put_request(url, headers=headers, body=body) + elif method.upper() == 'DELETE': + return self.delete_request(url, headers=headers) + else: + raise ValueError("Método HTTP inválido. Escolha entre 'GET', 'POST', 'PUT' ou 'DELETE'.") + + return response diff --git a/thorpe_base/models/update_nodes.py b/thorpe_base/models/update_nodes.py new file mode 100644 index 0000000..cfc4875 --- /dev/null +++ b/thorpe_base/models/update_nodes.py @@ -0,0 +1,42 @@ +import logging +import json +from odoo import models, api +from . import thorpe_request + +_logger = logging.getLogger(__name__) + +class UpdateNodes(models.Model): + _name = 'thorpe.update.nodes' + _description = 'methods to update nodes values' + + @api.model + def update_nodes(self): + _logger.info("-----------------------------------------------------") + _logger.info("starting update nodes") + _logger.info("-----------------------------------------------------") + providers = self.env['thorpe.base'].search([]) + for provider in providers: + try: + request = thorpe_request.ThorpeRequest() + response = request.make_request(provider, '/nodes', 'GET', None) + data = response.json() + node_list = data.get('data') + for item in node_list: + node_name = item.get('node') + status = item.get('status') + + node_record = self.env['thorpe.base.node'].search([('name', '=', node_name)], limit=1) + + if not node_record: + node_record = self.env['thorpe.base.node'].create({ + 'name': node_name, + 'pve_id': provider.id, + 'status': status + }) + + node_record.write({ + 'pve_id': provider.id, + 'status': status, + }) + except Exception as e: + _logger.error("Erro ao processar nó do provedor %s: %s" % (provider.name, str(e))) diff --git a/thorpe_base/models/update_storages.py b/thorpe_base/models/update_storages.py new file mode 100644 index 0000000..cddca3b --- /dev/null +++ b/thorpe_base/models/update_storages.py @@ -0,0 +1,47 @@ +import logging +import json +from odoo import models, api +from . import thorpe_request + +_logger = logging.getLogger(__name__) + +class UpdateStorage(models.Model): + _name = 'thorpe.update.storage' + _description = 'methodos to update storage models' + + @api.model + def update_storages(self): + # Consulta para obter todos os Nodes + _logger.info("-----------------------------------------------------") + _logger.info("atualiza_storages_com_node") + nodes = self.env['thorpe.base.node'].search([('selected_to_sales', '=', True)]) + providers = self.env['thorpe.base'].search([]) + provider = providers[0] + for node in nodes: + try: + request = thorpe_request.ThorpeRequest() + url = f"/nodes/{node.name}/storage" + + response = request.make_request(provider, url, 'GET', None) + _logger.info(f"response: {response.text}") + data = response.json() + storage_list = data.get('data') + for item in storage_list: + storage = item.get('storage') + used_fraction = item.get('used_fraction') + + storage_record = self.env['thorpe.base.storage'].search([('name', '=', storage)], limit=1) + + if not storage_record: + storage_record = self.env['thorpe.base.storage'].create({ + 'name': storage, + 'node_id': node.id, + 'used_fraction': used_fraction + }) + + storage_record.write({ + 'node_id': node.id, + 'used_fraction': used_fraction, + }) + except Exception as e: + _logger.error("Erro ao processar nó do provedor %s: %s" % (nodes.name, str(e))) diff --git a/thorpe_base/readme/CONFIGURE.md b/thorpe_base/readme/CONFIGURE.md new file mode 100644 index 0000000..c8fad61 --- /dev/null +++ b/thorpe_base/readme/CONFIGURE.md @@ -0,0 +1,8 @@ +[ This file is optional, it should explain how to configure + the module before using it; it is aimed at advanced users. ] + +To configure this module, you need to: + +- Go to ... + +![alternative description]()../static/description/image.png) diff --git a/thorpe_base/readme/CONTEXT.md b/thorpe_base/readme/CONTEXT.md new file mode 100644 index 0000000..cdc297a --- /dev/null +++ b/thorpe_base/readme/CONTEXT.md @@ -0,0 +1,13 @@ +[ This file is optional but strongly suggested to allow end-users to evaluate the +module's usefulness in their context. ] + +It should explain the “why” of the module: + +- in which context or use cases this module can be useful (practical examples are welcome!). +- what is the business requirement that generated the need to develop this module + +It can also inform on related modules: + +- modules it depends on and their features +- other modules that can work well together with this one +- suggested setups where the module is useful (eg: multicompany, multi-website) diff --git a/thorpe_base/readme/CONTRIBUTORS.md b/thorpe_base/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..7be72fb --- /dev/null +++ b/thorpe_base/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Firstname Lastname (optional company website url) +- Second Person (optional company website url) diff --git a/thorpe_base/readme/CREDITS.md b/thorpe_base/readme/CREDITS.md new file mode 100644 index 0000000..9c2b025 --- /dev/null +++ b/thorpe_base/readme/CREDITS.md @@ -0,0 +1,7 @@ +[ This file is optional and contains additional credits, other than + authors, contributors, and maintainers. ] + +The development of this module has been financially supported by: + +- Company 1 name +- Company 2 name diff --git a/thorpe_base/readme/DESCRIPTION.md b/thorpe_base/readme/DESCRIPTION.md new file mode 100644 index 0000000..fc84a0a --- /dev/null +++ b/thorpe_base/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +[ This file must be max 2-3 paragraphs, and is required. ] + +This module extends the functionality of ... to support ... +and to allow you to ... + diff --git a/thorpe_base/readme/HISTORY.md b/thorpe_base/readme/HISTORY.md new file mode 100644 index 0000000..a6daf58 --- /dev/null +++ b/thorpe_base/readme/HISTORY.md @@ -0,0 +1,22 @@ +[ The change log. The goal of this file is to help readers + understand changes between version. The primary audience is + end users and integrators. Purely technical changes such as + code refactoring must not be mentioned here. + + This file may contain ONE level of section titles, underlined + with the ~ (tilde) character. Other section markers are + forbidden and will likely break the structure of the README.rst + or other documents where this fragment is included. ] + +## 11.0.x.y.z (YYYY-MM-DD) + +- [BREAKING] Breaking changes come first. + ([#70](https://github.com/OCA/repo/issues/70)) +- [ADD] New feature. + ([#74](https://github.com/OCA/repo/issues/74)) +- [FIX] Correct this. + ([#71](https://github.com/OCA/repo/issues/71)) + +## 11.0.x.y.z (YYYY-MM-DD) + +- ... diff --git a/thorpe_base/readme/INSTALL.md b/thorpe_base/readme/INSTALL.md new file mode 100644 index 0000000..77b98e7 --- /dev/null +++ b/thorpe_base/readme/INSTALL.md @@ -0,0 +1,7 @@ +[ This file must only be present if there are very specific + installation instructions, such as installing non-python + dependencies. The audience is systems administrators. ] + +To install this module, you need to: + +1. Do this ... diff --git a/thorpe_base/readme/ROADMAP.md b/thorpe_base/readme/ROADMAP.md new file mode 100644 index 0000000..446840c --- /dev/null +++ b/thorpe_base/readme/ROADMAP.md @@ -0,0 +1,5 @@ +[ Enumerate known caveats and future potential improvements. + It is mostly intended for end-users, and can also help + potential new contributors discovering new features to implement. ] + +- ... diff --git a/thorpe_base/readme/USAGE.md b/thorpe_base/readme/USAGE.md new file mode 100644 index 0000000..35260d6 --- /dev/null +++ b/thorpe_base/readme/USAGE.md @@ -0,0 +1,11 @@ +[ This file must be present and contains the usage instructions + for end-users. As all other rst files included in the README, + it MUST NOT contain reStructuredText sections + only body text (paragraphs, lists, tables, etc). Should you need + a more elaborate structure to explain the addon, please create a + Sphinx documentation (which may include this file as a "quick start" + section). ] + +To use this module, you need to: + +1. Go to ... diff --git a/thorpe_base/security/ir.model.access.csv b/thorpe_base/security/ir.model.access.csv new file mode 100644 index 0000000..d7714ea --- /dev/null +++ b/thorpe_base/security/ir.model.access.csv @@ -0,0 +1,5 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_thorpe_base_user,thorpe.base.model_access_user,model_thorpe_base,base.group_user,1,1,1,1 +access_thorpe_base_user,thorpe.base.model_access_user,model_thorpe_base_node,base.group_user,1,1,1,1 +access_thorpe_base_user,thorpe.base.model_access_user,model_thorpe_base_storage,base.group_user,1,1,1,1 + diff --git a/thorpe_base/static/description/icon.png b/thorpe_base/static/description/icon.png new file mode 100644 index 0000000..c9cc858 Binary files /dev/null and b/thorpe_base/static/description/icon.png differ diff --git a/thorpe_base/static/img/icon.png b/thorpe_base/static/img/icon.png new file mode 100644 index 0000000..ac16b30 Binary files /dev/null and b/thorpe_base/static/img/icon.png differ diff --git a/thorpe_base/views/menu.xml b/thorpe_base/views/menu.xml new file mode 100644 index 0000000..3b221c6 --- /dev/null +++ b/thorpe_base/views/menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/thorpe_base/views/thorpe_base.xml b/thorpe_base/views/thorpe_base.xml new file mode 100644 index 0000000..a1a03a1 --- /dev/null +++ b/thorpe_base/views/thorpe_base.xml @@ -0,0 +1,42 @@ + + + + Thorpe Base + thorpe.base + ir.actions.act_window + tree,form + + + + thorpe.base.list.view + thorpe.base + + + + + + + + + + thorpe.base.form.view + thorpe.base + +
+ + + + + + + + + + + + + +
+
+
+
diff --git a/thorpe_base/views/thorpe_nodes.xml b/thorpe_base/views/thorpe_nodes.xml new file mode 100644 index 0000000..6b3552a --- /dev/null +++ b/thorpe_base/views/thorpe_nodes.xml @@ -0,0 +1,21 @@ + + + + Thorpe Nodes + thorpe.base.node + ir.actions.act_window + tree,form + + + + thorpe.base.node.list.view + thorpe.base.node + + + + + + + + + \ No newline at end of file diff --git a/thorpe_base/views/thorpe_storages.xml b/thorpe_base/views/thorpe_storages.xml new file mode 100644 index 0000000..d3409df --- /dev/null +++ b/thorpe_base/views/thorpe_storages.xml @@ -0,0 +1,21 @@ + + + + Thorpe Storages + thorpe.base.storage + ir.actions.act_window + tree,form + + + + thorpe.base.storage.list.view + thorpe.base.storage + + + + + + + + + diff --git a/sales-thorpe/controllers/__init__.py b/thorpe_sales/__init__.py similarity index 50% rename from sales-thorpe/controllers/__init__.py rename to thorpe_sales/__init__.py index 457bae2..cde864b 100644 --- a/sales-thorpe/controllers/__init__.py +++ b/thorpe_sales/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -from . import controllers \ No newline at end of file +from . import models diff --git a/sales-thorpe/__manifest__.py b/thorpe_sales/__manifest__.py similarity index 87% rename from sales-thorpe/__manifest__.py rename to thorpe_sales/__manifest__.py index 9f2bd57..dad519c 100644 --- a/sales-thorpe/__manifest__.py +++ b/thorpe_sales/__manifest__.py @@ -5,10 +5,11 @@ 'description': 'Custom module to trigger actions on sales order confirmation and automate PVE deploy integration.', 'category': 'Sales', 'author': 'Marcos Méndez & Enieber Cunha | pop.coop', - 'depends': ['sale, sale_management'], + 'depends': ['sale'], 'data': [ 'views/sales_order_view.xml', ], + 'images': ['static/img/icon.png'], 'installable': True, 'application': False, 'auto_install': False, diff --git a/sales-thorpe/demo/demo.xml b/thorpe_sales/demo/demo.xml similarity index 100% rename from sales-thorpe/demo/demo.xml rename to thorpe_sales/demo/demo.xml diff --git a/sales-thorpe/models/__init__.py b/thorpe_sales/models/__init__.py similarity index 100% rename from sales-thorpe/models/__init__.py rename to thorpe_sales/models/__init__.py diff --git a/sales-thorpe/models/models.py b/thorpe_sales/models/models.py similarity index 92% rename from sales-thorpe/models/models.py rename to thorpe_sales/models/models.py index 322db06..06259fc 100644 --- a/sales-thorpe/models/models.py +++ b/thorpe_sales/models/models.py @@ -6,7 +6,6 @@ _logger = logging.getLogger(__name__) - @dataclass class LxcConfig: hostname: str @@ -32,13 +31,11 @@ class LxcPayload: tags: str -class SaleOrder(models.Model): +class SaleOrder(models.Model): _inherit = 'sale.order' - def action_confirm(self): - # Call the original method + def action_confirm(self): super(SaleOrder, self).action_confirm() - for order in self: self.create_lxc() @@ -73,7 +70,7 @@ def make_request(self, url_request, method, body=None): elif method.upper() == 'PUT': self.show_log("Request PUT") self.show_log(url) - response = requests.put(url, headers=headers, json=body, verify=False) + response = requests.put(url, headers=headers, data=body, verify=False) elif method.upper() == 'DELETE': self.show_log("Request DELETE") self.show_log(url) diff --git a/sales-thorpe/security/ir.model.access.csv b/thorpe_sales/security/ir.model.access.csv similarity index 100% rename from sales-thorpe/security/ir.model.access.csv rename to thorpe_sales/security/ir.model.access.csv diff --git a/thorpe_sales/static/img/icon.png b/thorpe_sales/static/img/icon.png new file mode 100644 index 0000000..82618d5 Binary files /dev/null and b/thorpe_sales/static/img/icon.png differ diff --git a/sales-thorpe/views/sales_order_view.xml b/thorpe_sales/views/sales_order_view.xml similarity index 100% rename from sales-thorpe/views/sales_order_view.xml rename to thorpe_sales/views/sales_order_view.xml diff --git a/sales-thorpe/views/templates.xml b/thorpe_sales/views/templates.xml similarity index 100% rename from sales-thorpe/views/templates.xml rename to thorpe_sales/views/templates.xml