Unverified Commit 34f1db1b by Paul B

espace-membre: Ajout PDFs des certificats fiscaux si disponible

Ce changement ajoute un lien vers le PDF de certificat fiscal, s'il
est disponible dans Odoo, dans la page d'info perso d'un membre.
parent 3eeeea34
Pipeline #1268 passed with stage
in 1 minute 28 seconds
......@@ -83,6 +83,27 @@ class CagetteMember(models.Model):
'id DESC')
@staticmethod
def retrieve_capital_certificate(keys):
api = OdooAPI()
cond = []
for k in keys:
cond.append([k, '=', keys[k]])
fields = ['display_name', 'partner_id', 'year',
'create_date', 'id']
return api.search_read('capital.certificate', cond, fields, 1, 0,
'id DESC')
@staticmethod
def retrieve_attachment_file(keys):
api = OdooAPI()
cond = []
for k in keys:
cond.append([k, '=', keys[k]])
fields = ['datas_fname', 'datas']
return api.search_read('ir.attachment', cond, fields, 1, 0,
'id DESC')
@staticmethod
def get_credentials(request):
import hashlib
......@@ -162,6 +183,14 @@ class CagetteMember(models.Model):
"""Get member data using Odoo API."""
return CagetteMember.retrieve_data_according_keys({'id':self.id}, full)
def get_capital_certificate_data(self):
"""Get member capital certificate data using Odoo API."""
return CagetteMember.retrieve_capital_certificate({'partner_id':self.id})
def get_capital_certificate_file(self, certificate_id):
"""Get member capital certificate file using Odoo API."""
return CagetteMember.retrieve_attachment_file({'res_id': certificate_id, 'res_model': 'capital.certificate'})
@staticmethod
def standalone_create_envelops(request):
res = {}
......
......@@ -114,6 +114,12 @@
<p>
Montant souscription : {{data.amount_subscription}} euros
</p>
{% if data.certificate_filename %}
<p>
<a href="{{data.certificate_binary}}" download="{{data.certificate_filename}}">Télécharger mon certificat fiscal de {{data.certificate_year}}</a>
</p>
{% endif %}
{% if data.active_tmpl_reg_line_count %}
<hr />
{% if data.is_exempted %}
......@@ -153,4 +159,4 @@
</div>
<script src="{% static 'js/all_common.js' %}?v="></script>
<script src="{% static 'js/info_perso.js' %}?v="></script>
{% endblock %}
\ No newline at end of file
{% endblock %}
......@@ -137,6 +137,13 @@ def info_perso(request):
# recupérer 'partner_owned_share_ids'
if len(m_data) > 0:
template_data = m_data[0]
certificate_data = m.get_capital_certificate_data()
if len(certificate_data) > 0:
certificate_file = m.get_capital_certificate_file(certificate_data[0]['id'])
if len(certificate_file) > 0:
template_data['certificate_year'] = certificate_data[0]['year']
template_data['certificate_filename'] = certificate_file[0]['datas_fname']
template_data['certificate_binary'] = 'data:application/pdf;base64,%s' % certificate_file[0]['datas']
img_src = ''
if template_data['image_medium']:
try:
......
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