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

[add] report contribution

parent ab7bd9d6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -2,3 +2,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models
from . import report
# © 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
# © 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"
_depends = {
'account.invoice': [
'year', 'type_contribution_id', 'partner_id',
'amount_total_signed', 'residual_company_signed',
'state', 'type', 'is_contribution'
],
'scop.contribution.riga': [
'year', 'type_contribution_id', 'partner_id',
'amount', 'amount_paid', 'amount_due',
'is_loss'
]
}
def _subquery(self):
query = super(ScopContributionReport, self)._subquery()
query += """
UNION ALL (
SELECT
year,
type_contribution_id,
partner_id,
SUM(amount) AS amount_called,
COALESCE(SUM(amount_paid), 0.0) AS amount_paid,
COALESCE(SUM(amount_due), 0.0) AS amount_due,
BOOL_OR(is_loss) AS is_loss
FROM
scop_contribution_riga
GROUP BY
year,
type_contribution_id,
partner_id
)
"""
return query
# ------------------------------------------------------
# Computed fields
# ------------------------------------------------------
def _get_payment(self):
self.ensure_one()
if self.year < '2021':
contribution_ids = self.env['scop.contribution.riga'].search([
('year', '=', self.year),
('partner_id', '=', self.partner_id.id),
('type_contribution_id', '=', self.type_contribution_id.id),
])
payment_ids = contribution_ids.mapped('payment_ids')
if payment_ids:
payments = payment_ids.mapped(lambda p: {
'date': p.date,
'name': p.libelle,
'ref': '',
'credit': p.amount,
})
payments_html = self._get_html_table(payments)
else:
payments_html = "<p>Il n'y a pas de paiements associés à cette cotisation</p>"
else:
payments_html = super(ScopContributionReport, self)._get_payment()
return payments_html
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