diff --git a/__init__.py b/__init__.py index 8871070722787374e6f51f62f0f636847d986285..f88059b176b68c16a1a1024c635a43d555e9229c 100755 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,7 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import controllers from . import models +from . import report from . import wizard diff --git a/__manifest__.py b/__manifest__.py index fb76d4ac3764ea6b77a41f35fa17dc7f9daca09b..54db846ab3ed89ec29ec6d4d43cd494a2f74f33f 100755 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,3 +1,5 @@ +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "CG SCOP - Cotisations CG", "summary": "CG SCOP - Cotisations CG Scop", @@ -23,9 +25,9 @@ "datas/queue_job_data.xml", "datas/ir_sequence_data.xml", # Reports - "report/report_scop_bordereau.xml", - "report/report_scop_bordereau_payments.xml", - "report/report_scop_bordereau_refund.xml", + "templates/report_scop_bordereau.xml", + "templates/report_scop_bordereau_payments.xml", + "templates/report_scop_bordereau_refund.xml", # Views "views/account_invoice.xml", "views/res_config_settings.xml", diff --git a/models/scop_bordereau_cg_version.py b/models/scop_bordereau_cg_version.py index 19b537239a69a2816e98ae07715a990034e20ab6..ef5e3217445f0f93c3314280e4383a49a91914e5 100644 --- a/models/scop_bordereau_cg_version.py +++ b/models/scop_bordereau_cg_version.py @@ -1,5 +1,6 @@ # © 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + from datetime import timedelta from odoo import fields, models, api diff --git a/report/__init__.py b/report/__init__.py new file mode 100755 index 0000000000000000000000000000000000000000..7b5fa1cac97787c466a30f5185a9cc5c65994f75 --- /dev/null +++ b/report/__init__.py @@ -0,0 +1,4 @@ +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +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..2fed4b43a0ae60c723e3785a5d16feb752f58563 --- /dev/null +++ b/report/scop_contribution_report.py @@ -0,0 +1,44 @@ +# © 2022 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class ScopContributionReport(models.Model): + _inherit = "scop.contribution.report" + + def _select_invoice(self): + select_str = super(ScopContributionReport, self)._select_invoice() + select_str = """ + SELECT + CAST(i.year AS VARCHAR), + i.type_contribution_id, + i.partner_id, + SUM(i.amount_total_signed) AS amount_called, + SUM(i.amount_total_signed - i.residual_company_signed) AS amount_paid, + SUM(i.residual_company_signed) AS amount_due, + ( + CASE WHEN max(refund.id) IS NOT NULL THEN true ELSE FALSE END OR + CASE WHEN max(refund_b.id) IS NOT NULL THEN true ELSE FALSE END + ) AS is_loss + """ + return select_str + + def _from_invoice(self): + from_str = super(ScopContributionReport, self)._from_invoice() + from_str += """ + LEFT JOIN + scop_bordereau b ON i.bordereau_id = b.id + LEFT JOIN + scop_bordereau refund_b ON b.id = refund_b.refund_id + """ + return from_str + + def _where_invoice(self): + where_str = super(ScopContributionReport, self)._where_invoice() + where_str += "AND (i.bordereau_id IS NULL OR b.is_regul = false OR b.is_regul IS NULL)" + return where_str + + # ------------------------------------------------------ + # Computed fields + # ------------------------------------------------------ diff --git a/report/report_scop_bordereau.xml b/templates/report_scop_bordereau.xml similarity index 100% rename from report/report_scop_bordereau.xml rename to templates/report_scop_bordereau.xml diff --git a/report/report_scop_bordereau_payments.xml b/templates/report_scop_bordereau_payments.xml similarity index 100% rename from report/report_scop_bordereau_payments.xml rename to templates/report_scop_bordereau_payments.xml diff --git a/report/report_scop_bordereau_refund.xml b/templates/report_scop_bordereau_refund.xml similarity index 100% rename from report/report_scop_bordereau_refund.xml rename to templates/report_scop_bordereau_refund.xml