diff --git a/__init__.py b/__init__.py
index 48e1758c82ff2acfdf8618bcbf8c4c296a4ed7f9..08831fcf07b8aa9f0a7b2c857e04996a2bc24138 100644
--- a/__init__.py
+++ b/__init__.py
@@ -2,4 +2,4 @@
# © 2020 Confédération Générale des Scop (<https://www.les-scop.coop>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from . import models
+from . import models, report
diff --git a/__manifest__.py b/__manifest__.py
index 6d85925db5db09de860cb12edba02dcb06cee103..e5dd73d422763606367cc74b2ae53c129ca2b1c5 100644
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -8,6 +8,7 @@
"license": "AGPL-3",
"depends": [
"cgscop_partner",
+ "cgscop_cotisation",
],
"data": [
# security
diff --git a/report/__init__.py b/report/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e6800d8ad16f18ee0a3bbe0d8b256a9dd17964b9
--- /dev/null
+++ b/report/__init__.py
@@ -0,0 +1 @@
+from . import scop_contribution_report
diff --git a/report/scop_contribution_report.py b/report/scop_contribution_report.py
new file mode 100644
index 0000000000000000000000000000000000000000..5b5c2c6cd0a56b68479d80ab44d2421e87009cc1
--- /dev/null
+++ b/report/scop_contribution_report.py
@@ -0,0 +1,88 @@
+# © 2022 Le Filament (<http://www.le-filament.com>)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+import logging
+
+from psycopg2.extensions import AsIs
+
+from odoo import api, fields, models, tools
+
+_logger = logging.getLogger(__name__)
+
+
+class ScopContributionReport(models.Model):
+ _inherit = "scop.contribution.report"
+
+ # ------------------------------------------------------
+ # Sub Query PACA
+ # ------------------------------------------------------
+ def _select_paca(self):
+
+ type_coti_ur = self.env.ref("cgscop_partner.riga_14399").id
+
+ select_str = """
+ SELECT
+ 'odoo' as source,
+ CAST(i.year AS VARCHAR),
+ %d AS type_contribution_id,
+ i.partner_id,
+ SUM(i.amount_contribution) AS amount_called,
+ SUM(i.amount_paid) AS amount_paid,
+ SUM(i.amount_contribution - i.amount_paid) AS amount_due
+ """ % (
+ type_coti_ur,
+ )
+ return select_str
+
+ def _from_paca(self):
+ from_str = """
+ FROM
+ scop_cotisation_paca i
+ """
+ return from_str
+
+ def _where_paca(self):
+ where_str = """
+ WHERE
+ i.partner_id IS NOT NULL
+ """
+ return where_str
+
+ def _groupby_paca(self):
+ groupby_str = """
+ GROUP BY
+ i.year,
+ i.partner_id
+ """
+ return groupby_str
+
+ def _query_paca(self):
+ query = "(%s %s %s %s)" % (
+ self._select_paca(),
+ self._from_paca(),
+ self._where_paca(),
+ self._groupby_paca(),
+ )
+ return query
+
+ def _subquerypaca(self):
+ return self._query_paca()
+
+ # ------------------------------------------------------
+ # Sub Query
+ # ------------------------------------------------------
+ def _subquery(self):
+ sub_query = super(ScopContributionReport, self)._subquery()
+ return f"{sub_query} UNION ALL {self._subquerypaca()}"
+
+ # ------------------------------------------------------
+ # Main Query
+ # ------------------------------------------------------
+
+ # ------------------------------------------------------
+ # Computed fields
+ # ------------------------------------------------------
+
+ # ------------------------------------------------------
+ # Business functions
+ # ------------------------------------------------------