Skip to content

Commit

Permalink
[ADD] medor_custom_stats
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-champonnois committed Jan 22, 2025
1 parent 175dcd8 commit 849d88c
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 0 deletions.
63 changes: 63 additions & 0 deletions medor_custom_stats/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/coopiteasy/addons/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 <https://github.com/coopiteasy/addons/issues/new?body=module:%20subscription_web_access%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Coop IT Easy SC

Contributors
~~~~~~~~~~~~

* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Victor Champonnois

Maintainers
~~~~~~~~~~~

This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/16.0/subscription_web_access>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions medor_custom_stats/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions medor_custom_stats/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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": [],
}
1 change: 1 addition & 0 deletions medor_custom_stats/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner
29 changes: 29 additions & 0 deletions medor_custom_stats/models/res_company.py
Original file line number Diff line number Diff line change
@@ -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)

1 change: 1 addition & 0 deletions medor_custom_stats/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* `Coop IT Easy SC <https://coopiteasy.be>`_
2 changes: 2 additions & 0 deletions medor_custom_stats/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Compute stats on number of subscribers and number of cooperators

Loading

0 comments on commit 849d88c

Please sign in to comment.