Improve: membership card printing

This commit is contained in:
younes 2025-08-03 10:34:19 +01:00
parent 627d698cca
commit 2eea9b6801
2 changed files with 7 additions and 22 deletions

View File

@ -38,8 +38,7 @@ class ResPartner(models.Model):
def server_action_get_card(self):
""" Used to fetch data from res. partner to pass in template"""
partner_id = self.env['res.partner'] \
.browse(self.env.context.get('active_ids'))
partner_id = self.env['res.partner'].sudo().browse(self.env.context.get('active_ids'))
company_id = self.env.company
if self.is_member:
data = {
@ -55,6 +54,6 @@ class ResPartner(models.Model):
image_url = base_url + '/web/image?' + 'model=product.product&id=' + str(partner_id.product_id.id) + '&field=card_background_image'
data['background_src'] = image_url or ''
return self.env.ref('membership_card_odoo.action_membership'
'_card').report_action(None, data=data)
'_card').sudo().report_action(None, data=data)
raise ValidationError(
'Need to buy membership inorder to print membership card')

View File

@ -30,36 +30,22 @@
<template id="print_member_ship_card">
<t t-call="web.html_container">
<!-- Header -->
<style>
@font-face {font-family: "Sakkal Majalla"; src:
url("/membership_card_odoo/static/fonts/ce7b5754581057e6f7444e2192850cc8.eot"); src:
url("/membership_card_odoo/static/fonts/ce7b5754581057e6f7444e2192850cc8.eot?#iefix")
format("embedded-opentype"),
url("/membership_card_odoo/static/fonts/ce7b5754581057e6f7444e2192850cc8.woff2") format("woff2"),
url("/membership_card_odoo/static/fonts/ce7b5754581057e6f7444e2192850cc8.woff") format("woff"),
url("/membership_card_odoo/static/fonts/ce7b5754581057e6f7444e2192850cc8.ttf") format("truetype");
}
.content{
font-family: 'Sakkal Majalla'!important;
}
</style>
<div t-attf-style="background-image: url('#{background_src}');background-size: 100% 100%; background-repeat: no-repeat; background-position: 0 0; height: 280mm; width: 450mm;"
style="font-family:'Sakkal Majalla'!important;" id="font" class="page content">
<div t-attf-style="background-image: url('#{background_src}');background-size: 100% 100%; background-repeat: no-repeat; background-position: 0 0; height: 280mm; width: 450mm;" class="page">
<div>
<div t-if="name"
style="position: absolute; top: 70mm; right: 160mm; font-family:'Sakkal Majalla'!important; font-size: 80px; font-weight: bold; text-align: right; direction: rtl;">
style="position: absolute; top: 70mm; right: 160mm; font-size: 60px; font-weight: bold; text-align: right; direction: rtl;">
<t t-esc="name"/>
</div>
<div t-if="membrship_no"
style="position: absolute; top: 95mm; right: 160mm; font-family:'Sakkal Majalla'!important; font-size: 80px; font-weight: bold; text-align: right; direction: rtl;">
style="position: absolute; top: 95mm; right: 160mm; font-size: 60px; font-weight: bold; text-align: right; direction: rtl;">
<t t-esc="membrship_no"/>
</div>
<div t-if="start_date"
style="position: absolute; top: 120mm; right: 160mm; font-family:'Sakkal Majalla'!important; font-size: 80px; font-weight: bold; text-align: right; direction: rtl;">
style="position: absolute; top: 120mm; right: 160mm; font-size: 60px; font-weight: bold; text-align: right; direction: rtl;">
<t t-esc="start_date"/>
</div>
<div t-if="end_date"
style="position: absolute; top: 145mm; right: 160mm; font-family:'Sakkal Majalla'!important; font-size: 80px; font-weight: bold; text-align: right; direction: rtl;">
style="position: absolute; top: 145mm; right: 160mm; font-size: 60px; font-weight: bold; text-align: right; direction: rtl;">
<t t-esc="end_date"/>
</div>
</div>