[Odoo 15.0] - [om_account_followup] - Subject Line on PDF Report
Opened this issue · 4 comments
Issue: Missing subject line on printed payment follow-up report
Howto: Steps to add subject line similar to text
- add "'get_title': self._get_title," to the _get_report_values return
- add "def _get_title" function
- add output to report
File: \om_account_followup\report\followup_print.py
Function: def _get_report_values
original code: return { 'docs': docs, 'doc_ids': docids, 'doc_model': model, 'time': time, 'ids_to_objects': self._ids_to_objects, 'getLines': self._lines_get, 'get_text': self._get_text, 'data': data and data['form'] or {}}
possible change: return { 'docs': docs, 'doc_ids': docids, 'doc_model': model, 'time': time, 'ids_to_objects': self._ids_to_objects, 'getLines': self._lines_get, 'get_text': self._get_text, 'get_title': self._get_title, 'data': data and data['form'] or {}}
File: \om_account_followup\report\followup_print.py
Function: def _get_title
possible change: def _get_title(self, stat_line, followup_id, context=None): fp_obj = self.env['followup.followup'] fp_line = fp_obj.browse(followup_id).followup_line if not fp_line: raise ValidationError( _("The followup plan defined for the current company does not " "have any followup action.")) default_title = '' li_delay = [] for line in fp_line: if not default_title and line.description: default_title = line.description li_delay.append(line.delay) li_delay.sort(reverse=True) partner_line_ids = self.env['account.move.line'].search( [('partner_id', '=', stat_line.partner_id.id), ('full_reconcile_id', '=', False), ('company_id', '=', stat_line.company_id.id), ('blocked', '=', False), ('debit', '!=', False), ('account_id.user_type_id.type', '=', 'receivable'), ('followup_line_id', '!=', False)]) partner_max_delay = 0 partner_max_title = '' for i in partner_line_ids: if i.followup_line_id.delay > partner_max_delay and \ i.followup_line_id.description: partner_max_delay = i.followup_line_id.delay partner_max_title = i.followup_line_id.name title = partner_max_delay and partner_max_title or default_title return title
opinion: its the same function which used for the _get_text but changed to return the title
File: \om_account_followup\views\report_followup.xml
original code: <p t-raw="get_text(o,data['followup_id']).replace('\n', '<br>')"/>
possible change: <p t-esc="get_title(o,data['followup_id'])"/> <p t-raw="get_text(o,data['followup_id']).replace('\n', '<br>')"/>
opinion: I'd prefer to have the title a bit bigger like the original odoo report subject lines but couldn't find a smart way to do it, for the moment i use <p style="font-size:2em;" t-esc="get_title(o,data['followup_id'])"/>
Thanks for the code snippet, we have tried this update locally before merging, if you have time, can you connect us in email or show us what changes it will be bring to the report by updating the above code
seems the image doesn't get uploaded
i've send the mail to your gmail.com address again