Skip to content
Extraits de code Groupes Projets
Valider 8bebdfb3 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[ADD] contribution in contribution report

parent 8584610e
Branches 14.0
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
# © 2020 Confédération Générale des Scop (<https://www.les-scop.coop>) # © 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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models, report
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"license": "AGPL-3", "license": "AGPL-3",
"depends": [ "depends": [
"cgscop_partner", "cgscop_partner",
"cgscop_cotisation",
], ],
"data": [ "data": [
# security # security
......
from . import scop_contribution_report
# © 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
# ------------------------------------------------------
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter