In an ODT file, how do I ensure that a certain section gets printed on a new page no matter how many records get printed before that section?
You must insert a page break before the starting of rendering the content for the record.
Most of the Tryton template are designed this way (pseudo-code):
<for each="record in records">
<page break/>
<record.rec_name/>
</for>
I get the following traceback
Traceback (most recent call last):
File "/Genshi-0.7.1-py3.6.egg/genshi/template/directives.py", line 109, in _parse_expr
lookup=template.lookup) or None
File "/Genshi-0.7.1-py3.6.egg/genshi/template/eval.py", line 80, in __init__
node = _parse(source, mode=self.mode)
File "/Genshi-0.7.1-py3.6.egg/genshi/template/eval.py", line 429, in _parse
return parse(source, mode)
File "/Genshi-0.7.1-py3.6.egg/genshi/template/astutil.py", line 22, in parse
return compile(source, '', mode, _ast.PyCF_ONLY_AST)
File "<string>", line 1
__relatorio_escape_invalid_chars(page break/)
^
SyntaxError: invalid syntax in expression "__relatorio_escape_invalid_chars(page break/)" of "replace" directive
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/trytond-5.0.6-py3.6.egg/trytond/wsgi.py", line 73, in dispatch_request
return endpoint(request, **request.view_args)
File "/trytond-5.0.6-py3.6.egg/trytond/protocols/dispatcher.py", line 46, in rpc
request, database_name, *request.rpc_params)
File "/trytond-5.0.6-py3.6.egg/trytond/wsgi.py", line 44, in auth_required
return wrapped(*args, **kwargs)
File "/trytond-5.0.6-py3.6.egg/trytond/protocols/wrappers.py", line 122, in wrapper
return func(request, pool, *args, **kwargs)
File "/trytond-5.0.6-py3.6.egg/trytond/protocols/dispatcher.py", line 176, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/trytond-5.0.6-py3.6.egg/trytond/report/report.py", line 182, in execute
oext, content = cls._execute(records, data, action_report)
File "/trytond-5.0.6-py3.6.egg/trytond/report/report.py", line 190, in _execute
return cls.convert(action, cls.render(action, report_context))
File "/trytond-5.0.6-py3.6.egg/trytond/report/report.py", line 290, in render
data = rel_report(**report_context).render()
File "/relatorio-0.8.1-py3.6.egg/relatorio/reporting.py", line 123, in __call__
return template.generate(**data).filter(*self.filters)
File "/relatorio-0.8.1-py3.6.egg/relatorio/templates/opendocument.py", line 841, in generate
stream = super(Template, self).generate(*args, **kwargs)
File "/Genshi-0.7.1-py3.6.egg/genshi/template/base.py", line 565, in generate
stream = self.stream
File "/Genshi-0.7.1-py3.6.egg/genshi/template/base.py", line 454, in stream
self._prepare_self()
File "/Genshi-0.7.1-py3.6.egg/genshi/template/base.py", line 473, in _prepare_self
self._stream = list(self._prepare(self._stream, inlined))
File "/Genshi-0.7.1-py3.6.egg/genshi/template/base.py", line 496, in _prepare
yield kind, (directives, list(substream)), pos
File "/Genshi-0.7.1-py3.6.egg/genshi/template/base.py", line 491, in _prepare
namespaces, pos)
File "/Genshi-0.7.1-py3.6.egg/genshi/template/directives.py", line 499, in attach
expr = cls._parse_expr(value, template, *pos[1:])
File "/Genshi-0.7.1-py3.6.egg/genshi/template/directives.py", line 114, in _parse_expr
offset + (err.offset or 0))
genshi.template.base.TemplateSyntaxError: invalid syntax in expression "__relatorio_escape_invalid_chars(page break/)" of "replace" directive (, line 1) (<string>, line 2378)
When I told about “page break”, it is in pseudo-code. You must use the actual “page break” from LibreOffice menu Insert > Page Break.
Thank You for helping.
The solution worked.
@ced,
I have a user who wants to select the records in the list view and then print them in a single go. However, each record needs to be printed from a new page. While trying the option, there is a blank page in the start (since we have given a Printed by, Printed on footer, it is appearing on the blank page). What is solution regarding the same?
If you have a starting blank page, it is because there are remaining content on it.
The best is too look at the fodt.