Hi people I hope all here,are doing well;
i have a question and i need some help .
The images are not showing in my PDF files. I have the pictures
added in binary file format. Here is an overview:
-
Python Code:
photo = fields.Binary("Photo")
-
Code XML:
<field name="my_photo" widget="image"/>
-
In the report:
<table:table-cell table:style-name="Table3.M_1" office:value-type="string">
<text:p text:style-name="P129"><draw:frame draw:style-name="fr2" draw:name="Bild3" text:anchor-type="paragraph" svg:x="0.071cm" svg:y="0.566cm" svg:width="4.14cm" svg:height="1.8cm" draw:z-index="6">
<draw:image loext:mime-type="image/png">
<office:binary-data>
<text:placeholder text:placeholder-type="text"><myphoto></text:placeholder>
</office:binary-data>
</draw:image>
</draw:frame></text:p>
</table:table-cell>
- The classes are:
class PrintCertificat(ModelView):
__name__ = 'party.print_certificat'
from_date = fields.Date('From Date', required=True)
to_date = fields.Date('To Date', required=True)
company = fields.Many2One('party.certificat', 'Company', required=True)//party.certificat is the class that does the
Contains image.
posted = fields.Boolean('Posted Move', help='Show only posted move')
@staticmethod
def default_from_date():
Date = Pool().get('ir.date')
return datetime.date(Date.today().year, 1, 1)
@staticmethod
def default_to_date():
Date = Pool().get('ir.date')
return Date.today()
@staticmethod
def default_to_date():
Date = Pool().get('ir.date')
return Date.today()
@staticmethod
def default_company():
return Transaction().context.get('company')
@staticmethod
def default_posted():
return False
class PrintCertificat(Wizard):
__name__ = 'party.print_certificat_'
start = StateView('party.print_certificat',
'module_name.print_certificat_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Print', 'print_', 'tryton-print', default=True),
])
print_ = StateReport('module_name.party.certificat_report')
def do_print_(self, action):
data = {
'company': self.start.company.id,
}
return action, data
class CertificatReport(Report):
__name__ = 'module_name.party.certificat_report'
@classmethod
def _get_records(cls, ids, model, data):
Move = Pool().get('party.certificat')
clause = [
]
@classmethod
def get_context(cls, records, data):
report_context['myphoto'] = company.photo
return report_context
indx = 0
report_context = super(CertificatReport, cls).get_context(records, data)
Company = Pool().get('party.certificat')
company = Company(data['company'])
report_context['company'] = company