I have created a form in Odoo and it contains fields with the translation feature.
The user has already entered the translated values, and I need to access them in order to use them in a QWebReport. Is it possible to to create a QWebReport that includes a value and it’s translation ??
I have tried to introduce a function that retrieves the translated values but when i try to use them in the QWebReport, it doesn’t recognize them. this is the function I used:
` def generate_report(self):
# Retrieve records
records = self.search([])
# Prepare data for the report
report_data = []
for record in records:
# Retrieve translated values of fields
trans_nom = record.with_context(lang='ar').nom
trans_prenom = record.with_context(lang='ar').prenom
trans_lieu_realisation = record.with_context(lang='ar').lieu_realisation
trans_decision_conseil = record.with_context(lang='ar').decision_conseil
# Append data to report_data list
report_data.append({
'trans_nom': trans_nom,
'trans_prenom': trans_prenom,
'trans_lieu_realisation': trans_lieu_realisation,
'trans_decision_conseil': trans_decision_conseil
})
# Render the Qwebreport with the data
report = self.env.ref('acces.imprimer_fiche_etudiant_action').render({
'docs': report_data,
})
return report`
I also tried if-else statement to make sure that there isn’t a problem somewhere else, but it only seems to not recognize the translated values, everything else works just fine.
I would really appreciate if anyone share their ideas and/or solutions about what could be done in such case.
Thank you so much.
Kaoutar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.