From 849d88c0c9e73e39d4ffa35c20293b6fddb6f75c Mon Sep 17 00:00:00 2001 From: Victor Champonnois Date: Wed, 22 Jan 2025 15:19:39 +0100 Subject: [PATCH] [ADD] medor_custom_stats --- medor_custom_stats/README.rst | 63 +++ medor_custom_stats/__init__.py | 1 + medor_custom_stats/__manifest__.py | 19 + medor_custom_stats/models/__init__.py | 1 + medor_custom_stats/models/res_company.py | 29 ++ medor_custom_stats/readme/CONTRIBUTORS.rst | 1 + medor_custom_stats/readme/DESCRIPTION.rst | 2 + .../static/description/index.html | 419 ++++++++++++++++++ 8 files changed, 535 insertions(+) create mode 100644 medor_custom_stats/README.rst create mode 100644 medor_custom_stats/__init__.py create mode 100644 medor_custom_stats/__manifest__.py create mode 100644 medor_custom_stats/models/__init__.py create mode 100644 medor_custom_stats/models/res_company.py create mode 100644 medor_custom_stats/readme/CONTRIBUTORS.rst create mode 100644 medor_custom_stats/readme/DESCRIPTION.rst create mode 100644 medor_custom_stats/static/description/index.html diff --git a/medor_custom_stats/README.rst b/medor_custom_stats/README.rst new file mode 100644 index 00000000..dcb9bb48 --- /dev/null +++ b/medor_custom_stats/README.rst @@ -0,0 +1,63 @@ +======================= +Subscription Web Access +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e6277d1efbd13b1fc76e2f38456be6d7616c807b91f162e748cb20ed5657d80d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Faddons-lightgray.png?logo=github + :target: https://github.com/coopiteasy/addons/tree/16.0/subscription_web_access + :alt: coopiteasy/addons + +|badge1| |badge2| |badge3| + +Adds a computed field "website access" that is used by third party applications to check wether a user has access to a website. +The computation is based on wether the partner's users has a contract ongoing. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Coop IT Easy SC + +Contributors +~~~~~~~~~~~~ + +* `Coop IT Easy SC `_: + + * Victor Champonnois + +Maintainers +~~~~~~~~~~~ + +This module is part of the `coopiteasy/addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/medor_custom_stats/__init__.py b/medor_custom_stats/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/medor_custom_stats/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/medor_custom_stats/__manifest__.py b/medor_custom_stats/__manifest__.py new file mode 100644 index 00000000..b6212b81 --- /dev/null +++ b/medor_custom_stats/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2021 Coop IT Easy SC +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Subscription Web Access", + "summary": ("Compute whether a partner has ongoing contracts"), + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Coop IT Easy SC", + "website": "https://github.com/coopiteasy/addons", + "depends": [ + "contract", + "cooperator" + ], + "data": [ + "views/res_partner.xml", + ], + "demo": [], +} diff --git a/medor_custom_stats/models/__init__.py b/medor_custom_stats/models/__init__.py new file mode 100644 index 00000000..91fed54d --- /dev/null +++ b/medor_custom_stats/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/medor_custom_stats/models/res_company.py b/medor_custom_stats/models/res_company.py new file mode 100644 index 00000000..8bb21b5f --- /dev/null +++ b/medor_custom_stats/models/res_company.py @@ -0,0 +1,29 @@ +from odoo import models, fields, api +import json + + +class ResCompany(models.Model): + _inherit = "res.company" + + nb_subscribers = fields.Integer( + string="Nb Subscribers", compute="_compute_company_data" + ) + nb_cooperators = fields.Integer( + string="Nb Cooperators", compute="_compute_company_data" + ) + + @api.multi + def _compute_company_data(self): + for company in self: + subscribers = ( + self.env["res.partner"] + .sudo() + .search([("subscriber", "=", True)]) + ) + company.nb_subscribers = len(subscribers) + + cooperators = ( + self.env["res.partner"].sudo().search([("member", "=", True)]) + ) + company.nb_cooperators = len(cooperators) + diff --git a/medor_custom_stats/readme/CONTRIBUTORS.rst b/medor_custom_stats/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..da71d59f --- /dev/null +++ b/medor_custom_stats/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* `Coop IT Easy SC `_ diff --git a/medor_custom_stats/readme/DESCRIPTION.rst b/medor_custom_stats/readme/DESCRIPTION.rst new file mode 100644 index 00000000..c036877e --- /dev/null +++ b/medor_custom_stats/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Compute stats on number of subscribers and number of cooperators + diff --git a/medor_custom_stats/static/description/index.html b/medor_custom_stats/static/description/index.html new file mode 100644 index 00000000..900d2fcd --- /dev/null +++ b/medor_custom_stats/static/description/index.html @@ -0,0 +1,419 @@ + + + + + +Subscription Web Access + + + +
+

Subscription Web Access

+ + +

Beta License: AGPL-3 coopiteasy/addons

+

Adds a computed field “website access” that is used by third party applications to check wether a user has access to a website. +The computation is based on wether the partner’s users has a contract ongoing.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Coop IT Easy SC
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the coopiteasy/addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ +