[FIX] l10n_de: ensure o is defined in din5008 report

How to reproduce the bug:

- install l10n_de
- in Settings/General Settings/Business Documents, configure document
  layout to DIN 5008
- try to print one of several:
   => timesheet entries
   => direct debit mandates
   => follow-up reports

Bug:

When you use the DIN 5008 report defined in l10n_de, the o variable is
defined which generates an error.

closes odoo/odoo#81505

Opw: 2659703,2699563,2649221
X-original-commit: c6ffe7eb65844dad33db4390ffeeb24d61a36f40
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
Adrien Minet
2021-12-18 21:00:49 +00:00
committed by william-andre
parent 144abbe552
commit 96dab7ac98
3 changed files with 22 additions and 3 deletions
+1
View File
@@ -3,3 +3,4 @@
from . import base_document_layout
from . import account_move
from . import hr_timesheet
@@ -0,0 +1,15 @@
from odoo import models, fields
class AccountAnalyticLine(models.Model):
_inherit = 'account.analytic.line'
l10n_din5008_template_data = fields.Binary(compute='_compute_l10n_din5008_template_data')
l10n_din5008_document_title = fields.Char(compute='_compute_l10n_din5008_document_title')
def _compute_l10n_din5008_template_data(self):
for record in self:
record.l10n_din5008_template_data = []
def _compute_l10n_din5008_document_title(self):
for record in self:
record.l10n_din5008_document_title = ''
@@ -100,9 +100,12 @@
</tr>
</table>
<h2>
<span t-if="not o"><t t-esc="company.l10n_din5008_document_title"/></span>
<span t-elif="'l10n_din5008_document_title' in o"><t t-esc="o.l10n_din5008_document_title"/></span>
<span t-else="" t-field="o.name"/>
<span t-if="not o and not docs"><t t-esc="company.l10n_din5008_document_title"/></span>
<span t-else="">
<t t-set="o" t-value="docs[0]" t-if="not o" />
<span t-if="'l10n_din5008_document_title' in o"><t t-esc="o.l10n_din5008_document_title"/></span>
<span t-else="" t-field="o.name"/>
</span>
</h2>
<t t-out="0"/>
</div>