[IMP] base_report_to_printer: Fix XMLRPC calls and tests

- When added the patch to be able to configure report copies by report object, the expected signature changed to expect a report object. That can't work through the XMLRPC interface, so we revert it to what it was before: expecting the report name.
- Some tests that were producing warnings are muted now.
- The tests that had been changed went back to normal too.
- Current implementation didn't produce the expected results when actually forcing to print 1 copy.
- Added a demo report to test, since searching the database for the 1st unkonwn report found is not very deterministic and can lead to problems, like those addressed in #122 and #123.
- Finally, this update requires a database upgrade, so I pushed correctly the manifest version too.
This commit is contained in:
Jairo Llopis
2018-04-09 09:53:41 +01:00
committed by Jairo Llopis
parent a946a2a570
commit 3eb0c70acb
9 changed files with 70 additions and 16 deletions

View File

@@ -73,6 +73,7 @@ class PrintingPrinter(models.Model):
}
return vals
# TODO Rename param report to report_name, to make behavior obvious
@api.multi
def print_options(self, report=None, format=None, copies=1):
""" Hook to set print options """
@@ -83,8 +84,9 @@ class PrintingPrinter(models.Model):
options['copies'] = str(copies)
return options
# TODO Rename param report to report_name, to make behavior obvious
@api.multi
def print_document(self, report, content, format, copies=1):
def print_document(self, report, content, format, copies=None):
""" Print a file
Format could be pdf, qweb-pdf, raw, ...
@@ -96,17 +98,19 @@ class PrintingPrinter(models.Model):
os.write(fd, content)
finally:
os.close(fd)
if copies == 1:
report_obj = self.env["report"]._get_report_from_name(report)
if copies is None:
# If number of copies is not indicated by argument, check context
# or report definition
copies = (
self.env.context.get('report_copies') or
(report and report.report_copies) or
copies
report_obj.report_copies or
1
)
return self.print_file(
file_name, report=report, copies=copies, format=format)
# TODO Rename param report to report_name, to make behavior obvious
@api.multi
def print_file(self, file_name, report=None, copies=1, format=None):
""" Print a file """