Skip to content

Commit

Permalink
[ADD] pingen_env
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaniszewska-dev committed Feb 26, 2024
1 parent b57c983 commit 848a89c
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions pingen_env/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
to update
5 changes: 5 additions & 0 deletions pingen_env/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from . import models
from .hooks import post_init_hook
17 changes: 17 additions & 0 deletions pingen_env/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "pingen.com server environment",
"version": "16.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Reporting",
"complexity": "easy",
"depends": ["pingen", "server_environment"],
"website": "https://github.com/OCA/report-print-send",
"post_init_hook": "post_init_hook",
"installable": True,
"auto_install": False,
"application": False,
}
15 changes: 15 additions & 0 deletions pingen_env/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)


def post_init_hook(cr, registry):
# When installing pingen_env we want to delete data from DB
cr.execute(
"""UPDATE res_company
SET pingen_clientid = NULL,
pingen_client_secretid = NULL,
pingen_organization = NULL,
pingen_staging = NULL,
pingen_webhook_secret = NULL;
"""
)
4 changes: 4 additions & 0 deletions pingen_env/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from . import res_company
45 changes: 45 additions & 0 deletions pingen_env/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models

from odoo.addons.server_environment import serv_config


class ResCompany(models.Model):
_inherit = ["res.company"]

pingen_clientid = fields.Char(
compute="_compute_pingen_env", required=False, readonly=True
)
pingen_client_secretid = fields.Char(
compute="_compute_pingen_env", required=False, readonly=True
)
pingen_organization = fields.Char(
compute="_compute_pingen_env", required=False, readonly=True
)
pingen_staging = fields.Boolean(
compute="_compute_pingen_env", required=False, readonly=True
)
pingen_webhook_secret = fields.Char(
compute="_compute_pingen_env", required=False, readonly=True
)

@api.depends()
def _compute_pingen_env(self):
global_section_name = "pingen"

Check warning on line 30 in pingen_env/models/res_company.py

View check run for this annotation

Codecov / codecov/patch

pingen_env/models/res_company.py#L30

Added line #L30 was not covered by tests
for company in self:
# default vals
config_vals = {

Check warning on line 33 in pingen_env/models/res_company.py

View check run for this annotation

Codecov / codecov/patch

pingen_env/models/res_company.py#L33

Added line #L33 was not covered by tests
"pingen_clientid": "",
"pingen_client_secretid": "",
"pingen_organization": "",
"pingen_staging": True,
"pingen_webhook_secret": "",
}
if serv_config.has_section(global_section_name):
config_vals.update(serv_config.items(global_section_name))
custom_section_name = global_section_name + "." + company.name

Check warning on line 42 in pingen_env/models/res_company.py

View check run for this annotation

Codecov / codecov/patch

pingen_env/models/res_company.py#L41-L42

Added lines #L41 - L42 were not covered by tests
if serv_config.has_section(custom_section_name):
config_vals.update(serv_config.items(custom_section_name))
company.update(config_vals)

Check warning on line 45 in pingen_env/models/res_company.py

View check run for this annotation

Codecov / codecov/patch

pingen_env/models/res_company.py#L44-L45

Added lines #L44 - L45 were not covered by tests
1 change: 1 addition & 0 deletions pingen_env/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Anna Janiszewska <[email protected]>
1 change: 1 addition & 0 deletions setup/pingen_env/odoo/addons/pingen_env
6 changes: 6 additions & 0 deletions setup/pingen_env/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 848a89c

Please sign in to comment.