Commit 3e45256b by François C.

Merge branch 'export_capital_detenu_par_membre' into 'dev_cooperatic'

Export capital detenu par membre

See merge request !77
parents 32139ab4 c3931802
# -*- 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.debug("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