Commit b7f21a76 by François COLOMBIER

Ajout module lacagette_exports, offrant une méthode pour récupérer le capital…

Ajout module lacagette_exports, offrant une méthode pour récupérer le capital détenu par les membres à une date donnée
parent cac9391a
# -*- coding: utf-8 -*-
from . import models
\ No newline at end of file
# -*- coding: utf-8 -*-
{
'name': "La Cagette Exports",
'summary': """
Implements methods to make SQL queries for exports purposes
""",
'description': """
""",
'author': "fracolo",
'website': "https://lacagette-coop.fr",
'category': 'Uncategorized',
'version': '0.0.1',
# any module necessary for this one to work correctly
'depends': ['base'],
# always loaded
'data': [
],
'installable': True,
}
# -*- coding: utf-8 -*-
from . import members
# -*- coding: utf-8 -*-
from openerp import models, fields, api
import logging
import datetime
_logger = logging.getLogger(__name__)
class LacagetteExports(models.Model):
_name = "lacagette.exports"
@api.model
def get_members_capital_at_date(self, params={}):
# _logger.info("Params reçus = %s", str(params))
# Params reçus = {'date': '2023-06-30', 'only_active': 0}
res = {}
try:
active_restriction = ''
if 'only_active' in params and params['only_active'] == 1:
active_restriction = """
AND
partner_id IN (SELECT id FROM res_partner WHERE active = true)"""
sql = """
SELECT
(SELECT display_name FROM res_partner WHERE id = partner_id) as membre,
capital_detenu
FROM
(
SELECT SUM(amount_total_signed) as capital_detenu, partner_id
FROM account_invoice
WHERE
is_capital_fundraising = true
AND
create_date <= '%s'
GROUP by partner_id
ORDER BY partner_id ASC
) as req_capital
WHERE
capital_detenu > 0
%s
ORDER BY partner_id ASC;
""" % (params['date'], active_restriction)
_logger.info("Requete = %s", sql)
self.env.cr.execute(sql)
res['data'] = self.env.cr.dictfetchall()
except Exception as e:
res['error'] = str(e)
return res
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment