diff --git a/__manifest__.py b/__manifest__.py index 5828f6d999fd60ee951c2533a081e273d41c2745..c548bac6c098970a4a7cfb6c1c752277d35fa275 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -16,6 +16,7 @@ "cgscop_account", "cgscop_liasse_fiscale", "cgscop_partner", + "cgscop_cotisation_paca", "lefilament_sales", ], "data": [ diff --git a/report/scop_contribution_report.py b/report/scop_contribution_report.py index 2240a5241308a8f70e88fad13b4b8271779bcbc1..f70132d3379faa6bebdf1784d9b441945e1761ff 100644 --- a/report/scop_contribution_report.py +++ b/report/scop_contribution_report.py @@ -50,6 +50,61 @@ class ScopContributionReport(models.Model): ], } + # ------------------------------------------------------ + # 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.annee AS VARCHAR), + %d AS type_contribution_id, + i.partner_id, + SUM(i.mt_coti) AS amount_called, + SUM(i.mt_paid) AS amount_paid, + SUM(i.mt_coti - i.mt_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.annee, + 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 # ------------------------------------------------------ @@ -137,6 +192,8 @@ class ScopContributionReport(models.Model): query = ( self._select() + self._subquery() + +" UNION ALL " + + self._subquerypaca() + ") c " + self._query_groupby() + self._query_order()