mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[10.0][IMP] base_report_to_printer: Copies number in print report
This commit is contained in:
committed by
Jairo Llopis
parent
2bae394d79
commit
a946a2a570
@@ -99,6 +99,8 @@ Contributors
|
||||
* Dave Lasley <dave@laslabs.com>
|
||||
* Sylvain Garancher <sylvain.garancher@syleam.fr>
|
||||
* Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
|
||||
* Luis M. Ontalba <luis.martinez@tecnativa.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
{
|
||||
'name': "Report to printer",
|
||||
'version': '10.0.1.0.3',
|
||||
'version': '10.0.1.0.4',
|
||||
'category': 'Generic Modules/Base',
|
||||
'author': "Agile Business Group & Domsense, Pegueroles SCP, NaN,"
|
||||
" LasLabs, Odoo Community Association (OCA)",
|
||||
"LasLabs, Odoo Community Association (OCA)",
|
||||
'website': 'http://www.agilebg.com',
|
||||
'license': 'AGPL-3',
|
||||
"depends": ['report'],
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
|
||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
||||
# Copyright 2015 Oihane Crucelaegui - AvanzOSC
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
@@ -21,6 +22,10 @@ class IrActionsReportXml(models.Model):
|
||||
string='Action',
|
||||
company_dependent=True,
|
||||
)
|
||||
report_copies = fields.Integer(
|
||||
string="# Copies",
|
||||
default=1,
|
||||
)
|
||||
printing_printer_id = fields.Many2one(
|
||||
comodel_name='printing.printer',
|
||||
string='Printer'
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
|
||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
||||
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
|
||||
# Copyright 2015 Oihane Crucelaegui - AvanzOSC
|
||||
# Copyright 2017 Luis M. Ontalba - Tecnativa
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import logging
|
||||
@@ -94,7 +96,14 @@ class PrintingPrinter(models.Model):
|
||||
os.write(fd, content)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
if copies == 1:
|
||||
# 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
|
||||
)
|
||||
return self.print_file(
|
||||
file_name, report=report, copies=copies, format=format)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# Copyright 2017 Tecnativa.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import tempfile
|
||||
@@ -31,6 +32,9 @@ class TestPrintingPrinter(TransactionCase):
|
||||
'location': 'Location',
|
||||
'uri': 'URI',
|
||||
}
|
||||
self.report = self.env['ir.actions.report.xml'].search([
|
||||
('report_type', '=', 'qweb-pdf'),
|
||||
], limit=1)
|
||||
|
||||
def new_record(self):
|
||||
return self.Model.create(self.printer_vals)
|
||||
@@ -55,7 +59,7 @@ class TestPrintingPrinter(TransactionCase):
|
||||
with mock.patch('%s.mkstemp' % model) as mkstemp:
|
||||
mkstemp.return_value = fd, file_name
|
||||
printer = self.new_record()
|
||||
printer.print_document('report_name', 'content to print', 'pdf')
|
||||
printer.print_document(self.report, 'content to print', 'pdf')
|
||||
cups.Connection().printFile.assert_called_once_with(
|
||||
printer.system_name,
|
||||
file_name,
|
||||
@@ -72,7 +76,7 @@ class TestPrintingPrinter(TransactionCase):
|
||||
printer = self.new_record()
|
||||
with self.assertRaises(UserError):
|
||||
printer.print_document(
|
||||
'report_name', 'content to print', 'pdf')
|
||||
self.report, 'content to print', 'pdf')
|
||||
|
||||
@mock.patch('%s.cups' % server_model)
|
||||
def test_print_file(self, cups):
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
<page string="Print" name="print" >
|
||||
<group>
|
||||
<field name="property_printing_action_id"/>
|
||||
<field name="report_copies"/>
|
||||
<field name="printing_printer_id"/>
|
||||
</group>
|
||||
|
||||
<separator string="Specific actions per user"/>
|
||||
<field name="printing_action_ids"/>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user