Browse Source

May 20: [FIX] Bug Fixed 'pdf_report_with_watermark'

pull/380/head
Cybrosys Technologies 2 months ago
parent
commit
0fe543a015
  1. 11
      pdf_report_with_watermark/models/res_company.py
  2. 108
      pdf_report_with_watermark/report/pdf_with_watermark.xml

11
pdf_report_with_watermark/models/res_company.py

@ -43,3 +43,14 @@ class ResCompany(models.Model):
background_image = fields.Image(string='Image', help='Select the image')
rotating_angle = fields.Float(string='Angle of Rotation',
help='Mention the angle of rotation')
class BaseDocumentLayout(models.TransientModel):
_inherit = 'base.document.layout'
watermark = fields.Boolean(related='company_id.watermark')
content_text = fields.Char(related='company_id.content_text')
watermark_type = fields.Selection(related='company_id.watermark_type')
color_picker = fields.Char(related='company_id.color_picker')
font_size = fields.Integer(related='company_id.font_size')
background_image = fields.Image(related='company_id.background_image')
rotating_angle = fields.Float(related='company_id.rotating_angle')

108
pdf_report_with_watermark/report/pdf_with_watermark.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Apply the watermark to the pdf report with mentioned specifications-->
<odoo>
<template id="pdf_watermark_report" inherit_id="web.external_layout_standard">
<template id="pdf_watermark_report_external" inherit_id="web.external_layout_standard">
<xpath expr="//div[hasclass('row')][last()]" position="after">
<t t-if="company.watermark">
<div class="row"
@ -27,4 +27,108 @@
</t>
</xpath>
</template>
</odoo>
<template id="pdf_watermark_report_boxed" inherit_id="web.external_layout_boxed">
<xpath expr="//div[hasclass('row')][last()]" position="after">
<t t-if="company.watermark">
<div class="row"
style="height:200px; width:300px;margin-left:30%;margin-top:50%;">
<div class="col-6" name="watermark">
<span t-attf-style="-webkit-transform:rotate(-{{company.rotating_angle}}deg);color:{{company.color_picker}};font-size:{{company.font_size}}px;text-align:center;position:absolute;text-align:center;opacity:0.25;">
<t t-if="company.watermark_type == 'text'">
<t t-esc="company.content_text"/>
</t>
<t t-if="company.watermark_type == 'image'">
<img t-if="company.background_image"
t-att-src="image_data_uri(company.background_image)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
<t t-if="company.watermark_type == 'logo'">
<img t-if="company.logo"
t-att-src="image_data_uri(company.logo)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
</span>
</div>
</div>
</t>
</xpath>
</template>
<template id="pdf_watermark_report_bold" inherit_id="web.external_layout_bold">
<xpath expr="//div[hasclass('row')][last()]" position="after">
<t t-if="company.watermark">
<div class="row"
style="height:200px; width:300px;margin-left:30%;margin-top:50%;">
<div class="col-6" name="watermark">
<span t-attf-style="-webkit-transform:rotate(-{{company.rotating_angle}}deg);color:{{company.color_picker}};font-size:{{company.font_size}}px;text-align:center;position:absolute;text-align:center;opacity:0.25;">
<t t-if="company.watermark_type == 'text'">
<t t-esc="company.content_text"/>
</t>
<t t-if="company.watermark_type == 'image'">
<img t-if="company.background_image"
t-att-src="image_data_uri(company.background_image)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
<t t-if="company.watermark_type == 'logo'">
<img t-if="company.logo"
t-att-src="image_data_uri(company.logo)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
</span>
</div>
</div>
</t>
</xpath>
</template>
<template id="pdf_watermark_report_striped" inherit_id="web.external_layout_striped">
<xpath expr="//div[hasclass('o_background_header')][last()]" position="after">
<t t-if="company.watermark">
<div class="row"
style="height:200px; width:300px;margin-left:30%;margin-top:50%;">
<div class="col-6" name="watermark">
<span t-attf-style="-webkit-transform:rotate(-{{company.rotating_angle}}deg);color:{{company.color_picker}};font-size:{{company.font_size}}px;text-align:center;position:absolute;text-align:center;opacity:0.25;">
<t t-if="company.watermark_type == 'text'">
<t t-esc="company.content_text"/>
</t>
<t t-if="company.watermark_type == 'image'">
<img t-if="company.background_image"
t-att-src="image_data_uri(company.background_image)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
<t t-if="company.watermark_type == 'logo'">
<img t-if="company.logo"
t-att-src="image_data_uri(company.logo)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
</span>
</div>
</div>
</t>
</xpath>
</template>
<template id="pdf_watermark_report_internal" inherit_id="web.internal_layout">
<xpath expr="//div[hasclass('row')][last()]" position="after">
<t t-if="company.watermark">
<div class="row"
style="height:200px; width:300px;margin-left:30%;margin-top:50%;">
<div class="col-6" name="watermark">
<span t-attf-style="-webkit-transform:rotate(-{{company.rotating_angle}}deg);color:{{company.color_picker}};font-size:{{company.font_size}}px;text-align:center;position:absolute;text-align:center;opacity:0.25;">
<t t-if="company.watermark_type == 'text'">
<t t-esc="company.content_text"/>
</t>
<t t-if="company.watermark_type == 'image'">
<img t-if="company.background_image"
t-att-src="image_data_uri(company.background_image)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
<t t-if="company.watermark_type == 'logo'">
<img t-if="company.logo"
t-att-src="image_data_uri(company.logo)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
</span>
</div>
</div>
</t>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save