Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] report_print_send: allow to print report from zebra printer changing from PDF format to HTML format #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ addons:
- python-lxml # because pip installation is slow
- cups
- libcups2-dev
- python-lxml

language: python
python:
Expand All @@ -31,6 +32,7 @@ install:
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
- pip install --upgrade lxml==3.6.4

script:
- travis_run_tests
Expand Down
10 changes: 10 additions & 0 deletions base_report_to_printer/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
##############################################################################

from openerp import models, exceptions, _, api
from lxml import etree


class Report(models.Model):
Expand Down Expand Up @@ -82,6 +83,15 @@ def get_pdf(self, cr, uid, ids, report_name, html=None,
can_print_report = self._can_print_report(cr, uid, ids,
behaviour, printer, document,
context=context)
if report.usage == 'zebra' and printer:
arch = self.get_html(
cr, uid, ids, report_name, data=data, context=context)
tree = etree.fromstring(arch)
code = tree.xpath("//div[@class='code']")
res = code[0].text if code else ''
res = '\n'.join([l.strip() for l in res.split('\n') if l.strip()])
res += '\n'
return res
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test variable can_be_printed also pliz on this if

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this validation is no necessary because this variable is by default skipped
This is the validation

and this is always skipped at least by context

if can_print_report:
printer.print_document(report, document, report.report_type)
return document
Expand Down