Improve: membership card printing
This commit is contained in:
parent
5a6f0b208b
commit
627d698cca
|
|
@ -37,6 +37,7 @@
|
||||||
'data': [
|
'data': [
|
||||||
'report/membership_card_reports.xml',
|
'report/membership_card_reports.xml',
|
||||||
'data/ir_actions_server_data.xml',
|
'data/ir_actions_server_data.xml',
|
||||||
|
'views/product_template.xml',
|
||||||
],
|
],
|
||||||
'images': ['static/description/banner.png'],
|
'images': ['static/description/banner.png'],
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
|
|
||||||
|
|
@ -20,3 +20,4 @@
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
|
from . import product_template
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from odoo import fields,api, models,_
|
||||||
|
|
||||||
|
|
||||||
|
class ProductTemplate(models.Model):
|
||||||
|
_inherit = "product.template"
|
||||||
|
|
||||||
|
card_background_image = fields.Binary(string="Background Image")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,15 +44,16 @@ class ResPartner(models.Model):
|
||||||
if self.is_member:
|
if self.is_member:
|
||||||
data = {
|
data = {
|
||||||
'name': partner_id.name,
|
'name': partner_id.name,
|
||||||
'product_id': partner_id.product_id.name,
|
|
||||||
'membrship_level':partner_id.membrship_level.name,
|
|
||||||
'membrship_level_color':partner_id.membrship_level.color,
|
|
||||||
'membrship_no':partner_id.membrship_no,
|
'membrship_no':partner_id.membrship_no,
|
||||||
'image': partner_id.image_1920,
|
|
||||||
'start_date': partner_id.join_date,
|
'start_date': partner_id.join_date,
|
||||||
'end_date': partner_id.memebership_end_date,
|
'end_date': partner_id.memebership_end_date,
|
||||||
'company_name': company_id.name,
|
'company_name': company_id.name,
|
||||||
}
|
}
|
||||||
|
if partner_id.product_id.card_background_image:
|
||||||
|
param_obj = self.env['ir.config_parameter'].sudo()
|
||||||
|
base_url = param_obj.get_param('web.base.url')
|
||||||
|
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'
|
return self.env.ref('membership_card_odoo.action_membership'
|
||||||
'_card').report_action(None, data=data)
|
'_card').report_action(None, data=data)
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,16 @@
|
||||||
<field name="name">Custom Paper</field>
|
<field name="name">Custom Paper</field>
|
||||||
<field name="default" eval="True"/>
|
<field name="default" eval="True"/>
|
||||||
<field name="format">custom</field>
|
<field name="format">custom</field>
|
||||||
<field name="page_height">110</field>
|
<field name="page_height">85</field>
|
||||||
<field name="page_width">70</field>
|
<field name="page_width">54</field>
|
||||||
<field name="orientation">Landscape</field>
|
<field name="orientation">Landscape</field>
|
||||||
<field name="margin_top">5.00</field>
|
<field name="margin_top">0</field>
|
||||||
<field name="margin_bottom">5.00</field>
|
<field name="margin_bottom">0</field>
|
||||||
<field name="margin_left">7.0</field>
|
<field name="margin_left">0</field>
|
||||||
<field name="margin_right">7.0</field>
|
<field name="margin_right">0</field>
|
||||||
<field name="header_line" eval="False"/>
|
<field name="header_line" eval="False"/>
|
||||||
<field name="header_spacing">35</field>
|
<field name="header_spacing">0</field>
|
||||||
<field name="dpi">125</field>
|
<field name="dpi">300</field>
|
||||||
</record>
|
</record>
|
||||||
<!--Report Action-->
|
<!--Report Action-->
|
||||||
<record id="action_membership_card" model="ir.actions.report">
|
<record id="action_membership_card" model="ir.actions.report">
|
||||||
|
|
@ -26,10 +26,9 @@
|
||||||
<field name="paperformat_id"
|
<field name="paperformat_id"
|
||||||
ref="membership_card_odoo.paperformat_card"/>
|
ref="membership_card_odoo.paperformat_card"/>
|
||||||
</record>
|
</record>
|
||||||
<!-- Template to print Pdf. -->
|
<!-- Template to print Pdf. -->
|
||||||
<template id="print_member_ship_card">
|
<template id="print_member_ship_card">
|
||||||
<t t-call="web.html_container">
|
<t t-call="web.html_container">
|
||||||
<t t-set="company" t-value="user.company_id"/>
|
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<style>
|
<style>
|
||||||
@font-face {font-family: "Sakkal Majalla"; src:
|
@font-face {font-family: "Sakkal Majalla"; src:
|
||||||
|
|
@ -41,36 +40,31 @@
|
||||||
url("/membership_card_odoo/static/fonts/ce7b5754581057e6f7444e2192850cc8.ttf") format("truetype");
|
url("/membership_card_odoo/static/fonts/ce7b5754581057e6f7444e2192850cc8.ttf") format("truetype");
|
||||||
}
|
}
|
||||||
.content{
|
.content{
|
||||||
font-family: 'Sakkal Majalla'!important;
|
font-family: 'Sakkal Majalla'!important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div 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;"
|
||||||
<div t-attf-style="background-color:{{membrship_level_color }};">
|
style="font-family:'Sakkal Majalla'!important;" id="font" class="page content">
|
||||||
<div style="font-family:'Sakkal Majalla'!important;" class="content">
|
<div>
|
||||||
<center>
|
<div t-if="name"
|
||||||
<h2><t t-esc="company.name"/></h2>
|
style="position: absolute; top: 70mm; right: 160mm; font-family:'Sakkal Majalla'!important; font-size: 80px; font-weight: bold; text-align: right; direction: rtl;">
|
||||||
</center>
|
<t t-esc="name"/>
|
||||||
<center>
|
</div>
|
||||||
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" height="50" style="max-height: 80px;" alt="Logo"/>
|
<div t-if="membrship_no"
|
||||||
</center>
|
style="position: absolute; top: 95mm; right: 160mm; font-family:'Sakkal Majalla'!important; font-size: 80px; font-weight: bold; text-align: right; direction: rtl;">
|
||||||
</div><br/>
|
<t t-esc="membrship_no"/>
|
||||||
<!-- Content -->
|
</div>
|
||||||
<div style="font-family:'Sakkal Majalla'!important;" class="row mt32">
|
<div t-if="start_date"
|
||||||
<div style="width:20%;margin-top:10px;float:right">
|
style="position: absolute; top: 120mm; right: 160mm; font-family:'Sakkal Majalla'!important; font-size: 80px; font-weight: bold; text-align: right; direction: rtl;">
|
||||||
<img t-if="image" style="width: 120px; border-radius: 5px;"
|
<t t-esc="start_date"/>
|
||||||
t-attf-src="data:image/*;base64,{{image}}"/>
|
</div>
|
||||||
</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;">
|
||||||
<div style="width:70%;font-family:'Sakkal Majalla'!important;';margin-top:5px;float:left">
|
<t t-esc="end_date"/>
|
||||||
<p dir="rtl" t-if="name"><strong>الاسم:</strong> <t t-esc="name"/></p>
|
|
||||||
<p dir="rtl" t-if="membrship_no"><strong>رقم العضوية:</strong> <t t-esc="membrship_no"/></p>
|
|
||||||
<p dir="rtl" t-if="product_id"><strong> نوع العضوية:</strong> <t t-esc="product_id"/></p>
|
|
||||||
<p dir="rtl" t-if="membrship_level"><strong> العضوية:</strong> <t t-esc="membrship_level"/></p>
|
|
||||||
<p dir="rtl" t-if="end_date"><strong>تاريخ الانتهاء:</strong> <t t-esc="end_date"/></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="inherit_form_membership_product_background" model="ir.ui.view">
|
||||||
|
<field name="name">view.membership.product.form.inherit.background.image</field>
|
||||||
|
<field name="model">product.template</field>
|
||||||
|
<field name="inherit_id" ref="dev_membership.form_membership_product"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[hasclass('oe_title')]" position="before">
|
||||||
|
|
||||||
|
<field name="card_background_image" widget="image"
|
||||||
|
options="{'zoom': true,'size': [120, 120]}"
|
||||||
|
class="oe_avatar"/>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in New Issue