mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[PORT] Finalize move of printer_tray to base_report_to_printer,
fix tests as report param is not a string but recordset
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
|
||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
|
||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
@@ -14,7 +13,7 @@
|
||||
" LasLabs, Camptocamp, Odoo Community Association (OCA)",
|
||||
'website': 'http://www.agilebg.com',
|
||||
'license': 'AGPL-3',
|
||||
"depends": ['web'],
|
||||
"depends": ['web', 'base'],
|
||||
'data': [
|
||||
'data/printing_data.xml',
|
||||
'security/security.xml',
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
<field name="name">Send to Client</field>
|
||||
<field name="action_type">client</field>
|
||||
</record>
|
||||
<record model="printing.action" id="printing_action_3">
|
||||
<field name="name">Use User Defaults</field>
|
||||
<field name="action_type">user_default</field>
|
||||
</record>
|
||||
<!-- properties -->
|
||||
<record forcecreate="True" id="property_printing_action_id" model="ir.property">
|
||||
<field name="name">property_printing_action_id</field>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import ir_actions_report
|
||||
from . import printing_action
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
|
||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
@@ -14,12 +13,12 @@ class IrActionsReport(models.Model):
|
||||
|
||||
property_printing_action_id = fields.Many2one(
|
||||
comodel_name='printing.action',
|
||||
string='Action',
|
||||
string='Default Behaviour',
|
||||
company_dependent=True,
|
||||
)
|
||||
printing_printer_id = fields.Many2one(
|
||||
comodel_name='printing.printer',
|
||||
string='Printer'
|
||||
string='Default Printer'
|
||||
)
|
||||
printer_tray_id = fields.Many2one(
|
||||
comodel_name='printing.tray',
|
||||
@@ -48,7 +47,7 @@ class IrActionsReport(models.Model):
|
||||
report = self._get_report_from_name(report_name)
|
||||
if not report:
|
||||
return {}
|
||||
result = report.behaviour()[report]
|
||||
result = report.behaviour()
|
||||
serializable_result = {
|
||||
'action': result['action'],
|
||||
'printer_name': result['printer'].name,
|
||||
@@ -57,49 +56,34 @@ class IrActionsReport(models.Model):
|
||||
|
||||
@api.multi
|
||||
def behaviour(self):
|
||||
result = {}
|
||||
self.ensure_one()
|
||||
printer_obj = self.env['printing.printer']
|
||||
printing_act_obj = self.env['printing.report.xml.action']
|
||||
# Set hardcoded default action
|
||||
default_action = 'client'
|
||||
# Retrieve system wide printer
|
||||
default_printer = printer_obj.get_default()
|
||||
|
||||
# Retrieve user default values
|
||||
# Retrieve user defaults or system defaults
|
||||
user = self.env.user
|
||||
if user.printing_action:
|
||||
default_action = user.printing_action
|
||||
if user.printing_printer_id:
|
||||
default_printer = user.printing_printer_id
|
||||
action = user.printing_action or 'client'
|
||||
printer = user.printing_printer_id or printer_obj.get_default()
|
||||
|
||||
for report in self:
|
||||
action = default_action
|
||||
printer = default_printer
|
||||
# Retrieve report default values
|
||||
report_action = self.property_printing_action_id
|
||||
if report_action and report_action.action_type != 'user_default':
|
||||
action = report_action.action_type
|
||||
if self.printing_printer_id:
|
||||
printer = self.printing_printer_id
|
||||
|
||||
# Retrieve report default values
|
||||
report_action = report.property_printing_action_id
|
||||
if report_action and report_action.action_type != 'user_default':
|
||||
action = report_action.action_type
|
||||
if report.printing_printer_id:
|
||||
printer = report.printing_printer_id
|
||||
# Retrieve report-user specific values
|
||||
print_action = printing_act_obj.search([
|
||||
('report_id', '=', self.id),
|
||||
('user_id', '=', self.env.uid),
|
||||
('action', '!=', 'user_default'),
|
||||
], limit=1)
|
||||
if print_action:
|
||||
user_action = print_action.behaviour()
|
||||
action = user_action['action']
|
||||
if user_action['printer']:
|
||||
printer = user_action['printer']
|
||||
|
||||
# Retrieve report-user specific values
|
||||
print_action = printing_act_obj.search([
|
||||
('report_id', '=', report.id),
|
||||
('user_id', '=', self.env.uid),
|
||||
('action', '!=', 'user_default'),
|
||||
], limit=1)
|
||||
if print_action:
|
||||
user_action = print_action.behaviour()
|
||||
action = user_action['action']
|
||||
if user_action['printer']:
|
||||
printer = user_action['printer']
|
||||
|
||||
result[report] = {
|
||||
'action': action,
|
||||
'printer': printer,
|
||||
}
|
||||
return result
|
||||
return {'action': action, 'printer': printer}
|
||||
|
||||
@api.multi
|
||||
def print_document(self, record_ids, data=None):
|
||||
@@ -107,7 +91,7 @@ class IrActionsReport(models.Model):
|
||||
document = self.with_context(
|
||||
must_skip_send_to_printer=True).render_qweb_pdf(
|
||||
record_ids, data=data)
|
||||
behaviour = self.behaviour()[self]
|
||||
behaviour = self.behaviour()
|
||||
printer = behaviour['printer']
|
||||
if not printer:
|
||||
raise exceptions.Warning(
|
||||
@@ -138,7 +122,7 @@ class IrActionsReport(models.Model):
|
||||
document, doc_format = super(IrActionsReport, self).render_qweb_pdf(
|
||||
docids, data=data)
|
||||
|
||||
behaviour = self.behaviour()[self]
|
||||
behaviour = self.behaviour()
|
||||
printer = behaviour['printer']
|
||||
can_print_report = self._can_print_report(behaviour, printer, document)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
|
||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
|
||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
@@ -63,9 +62,20 @@ class PrintingPrinter(models.Model):
|
||||
|
||||
@api.multi
|
||||
def _prepare_update_from_cups(self, cups_connection, cups_printer):
|
||||
vals = super(PrintingPrinter, self)._prepare_update_from_cups(
|
||||
cups_connection, cups_printer)
|
||||
|
||||
mapping = {
|
||||
3: 'available',
|
||||
4: 'printing',
|
||||
5: 'error'
|
||||
}
|
||||
vals = {
|
||||
'name': cups_printer['printer-info'],
|
||||
'model': cups_printer.get('printer-make-and-model', False),
|
||||
'location': cups_printer.get('printer-location', False),
|
||||
'uri': cups_printer.get('device-uri', False),
|
||||
'status': mapping.get(cups_printer.get(
|
||||
'printer-state'), 'unknown'),
|
||||
'status_message': cups_printer.get('printer-state-message', ''),
|
||||
}
|
||||
printer_uri = cups_printer['printer-uri-supported']
|
||||
printer_system_name = printer_uri[printer_uri.rfind('/') + 1:]
|
||||
ppd_info = cups_connection.getPPD3(printer_system_name)
|
||||
@@ -104,25 +114,6 @@ class PrintingPrinter(models.Model):
|
||||
for tray in self.tray_ids.filtered(
|
||||
lambda record: record.system_name not in cups_trays.keys())
|
||||
])
|
||||
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def _prepare_update_from_cups(self, cups_connection, cups_printer):
|
||||
mapping = {
|
||||
3: 'available',
|
||||
4: 'printing',
|
||||
5: 'error'
|
||||
}
|
||||
vals = {
|
||||
'name': cups_printer['printer-info'],
|
||||
'model': cups_printer.get('printer-make-and-model', False),
|
||||
'location': cups_printer.get('printer-location', False),
|
||||
'uri': cups_printer.get('device-uri', False),
|
||||
'status': mapping.get(cups_printer.get(
|
||||
'printer-state'), 'unknown'),
|
||||
'status_message': cups_printer.get('printer-state-message', ''),
|
||||
}
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
|
||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
|
||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
@@ -33,6 +32,17 @@ class ResUsers(models.Model):
|
||||
domain="[('printer_id', '=', printing_printer_id)]",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _register_hook(self):
|
||||
self.SELF_WRITEABLE_FIELDS.extend([
|
||||
'printing_action',
|
||||
'printing_printer_id',
|
||||
])
|
||||
self.SELF_READABLE_FIELDS.extend([
|
||||
'printing_action',
|
||||
'printing_printer_id',
|
||||
])
|
||||
|
||||
@api.onchange('printing_printer_id')
|
||||
def onchange_printing_printer_id(self):
|
||||
""" Reset the tray when the printer is changed """
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<odoo noupdate="1">
|
||||
<data>
|
||||
<record id="printing_group_manager" model="res.groups">
|
||||
<field name="name">Printing / Print Manager</field>
|
||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||
|
||||
@@ -1,41 +1,46 @@
|
||||
odoo.define('base_report_to_printer.print', function(require) {
|
||||
odoo.define('base_report_to_printer.print', function (require) {
|
||||
'use strict';
|
||||
|
||||
var ActionManager = require('web.ActionManager');
|
||||
var core = require('web.core');
|
||||
var framework = require('web.framework');
|
||||
var Model = require('web.Model');
|
||||
var rpc = require('web.rpc');
|
||||
|
||||
|
||||
ActionManager.include({
|
||||
ir_actions_report: function(action, options) {
|
||||
action_val = _.clone(action);
|
||||
ir_actions_report: function (action, options) {
|
||||
var action_val = _.clone(action);
|
||||
var _t = core._t;
|
||||
var self = this;
|
||||
var _super = this._super;
|
||||
|
||||
if ('report_type' in action_val && action_val.report_type === 'qweb-pdf') {
|
||||
framework.blockUI();
|
||||
new Model('ir.actions.report').
|
||||
call('print_action_for_report_name', [action_val.report_name]).
|
||||
then(function(print_action){
|
||||
if (print_action && print_action.action_val === 'server') {
|
||||
framework.unblockUI();
|
||||
new Model('report').
|
||||
call('print_document',
|
||||
[action_val.context.active_ids, action_val.report_name],
|
||||
{data: action_val.data || {}, context: action_val.context || {}}).
|
||||
then(function(){
|
||||
self.do_notify(_t('Report'),
|
||||
_t('Document sent to the printer ') + print_action.printer_name);
|
||||
}).fail(function() {
|
||||
self.do_notify(_t('Report'),
|
||||
_t('Error when sending the document to the printer ') + print_action.printer_name);
|
||||
rpc.query({
|
||||
model: 'ir.actions.report',
|
||||
method: 'print_action_for_report_name',
|
||||
args: [action_val.report_name]
|
||||
}).then(function (print_action) {
|
||||
if (print_action && print_action.action_val === 'server') {
|
||||
framework.unblockUI();
|
||||
rpc.query({
|
||||
model: 'ir.actions.report',
|
||||
method: 'print_document',
|
||||
args: [action_val.context.active_ids, action_val.report_name],
|
||||
kwargs: {data: action_val.data || {}},
|
||||
context: action_val.context || {}
|
||||
}).then(function () {
|
||||
self.do_notify(_t('Report'),
|
||||
_t('Document sent to the printer ') + print_action.printer_name);
|
||||
}).fail(function () {
|
||||
self.do_notify(_t('Report'),
|
||||
_t('Error when sending the document to the printer ') + print_action.printer_name);
|
||||
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action_val, options]);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action_val, options]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return _super.apply(self, [action_val, options]);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# Copyright 2016 SYLEAM
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
@@ -67,7 +66,7 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
""" It should return correct serializable result for behaviour """
|
||||
with mock.patch.object(self.Model, '_get_report_from_name') as mk:
|
||||
res = self.Model.print_action_for_report_name('test')
|
||||
behaviour = mk().behaviour()[mk()]
|
||||
behaviour = mk().behaviour()
|
||||
expect = {
|
||||
'action': behaviour['action'],
|
||||
'printer_name': behaviour['printer'].name,
|
||||
@@ -85,10 +84,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
report.property_printing_action_id = False
|
||||
report.printing_printer_id = False
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': 'client',
|
||||
'printer': self.env['printing.printer'],
|
||||
},
|
||||
'action': 'client',
|
||||
'printer': self.env['printing.printer'],
|
||||
})
|
||||
|
||||
def test_behaviour_user_values(self):
|
||||
@@ -97,10 +94,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
self.env.user.printing_action = 'client'
|
||||
self.env.user.printing_printer_id = self.new_printer()
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': 'client',
|
||||
'printer': self.env.user.printing_printer_id,
|
||||
},
|
||||
'action': 'client',
|
||||
'printer': self.env.user.printing_printer_id,
|
||||
})
|
||||
|
||||
def test_behaviour_report_values(self):
|
||||
@@ -110,10 +105,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
report.property_printing_action_id = self.new_action()
|
||||
report.printing_printer_id = self.new_printer()
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': report.property_printing_action_id.action_type,
|
||||
'printer': report.printing_printer_id,
|
||||
},
|
||||
})
|
||||
|
||||
def test_behaviour_user_action(self):
|
||||
@@ -122,10 +115,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
self.env.user.printing_action = 'client'
|
||||
report.property_printing_action_id.action_type = 'user_default'
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': 'client',
|
||||
'printer': report.printing_printer_id,
|
||||
},
|
||||
})
|
||||
|
||||
def test_behaviour_printing_action_on_wrong_user(self):
|
||||
@@ -138,10 +129,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
('id', '!=', self.env.user.id),
|
||||
], limit=1)
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': 'client',
|
||||
'printer': report.printing_printer_id,
|
||||
},
|
||||
'action': 'client',
|
||||
'printer': report.printing_printer_id,
|
||||
})
|
||||
|
||||
def test_behaviour_printing_action_on_wrong_report(self):
|
||||
@@ -155,10 +144,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
('id', '!=', report.id),
|
||||
], limit=1)
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': 'client',
|
||||
'printer': report.printing_printer_id,
|
||||
},
|
||||
'action': 'client',
|
||||
'printer': report.printing_printer_id,
|
||||
})
|
||||
|
||||
def test_behaviour_printing_action_with_no_printer(self):
|
||||
@@ -170,10 +157,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
printing_action.user_id = self.env.user
|
||||
printing_action.report_id = report
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': printing_action.action,
|
||||
'printer': report.printing_printer_id,
|
||||
},
|
||||
})
|
||||
|
||||
def test_behaviour_printing_action_with_printer(self):
|
||||
@@ -184,10 +169,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
printing_action.user_id = self.env.user
|
||||
printing_action.printer_id = self.new_printer()
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': printing_action.action,
|
||||
'printer': printing_action.printer_id,
|
||||
},
|
||||
'action': printing_action.action,
|
||||
'printer': printing_action.printer_id,
|
||||
})
|
||||
|
||||
def test_behaviour_printing_action_user_defaults(self):
|
||||
@@ -199,10 +182,8 @@ class TestIrActionsReportXml(TransactionCase):
|
||||
printing_action.user_id = self.env.user
|
||||
printing_action.action = 'user_default'
|
||||
self.assertEqual(report.behaviour(), {
|
||||
report: {
|
||||
'action': 'client',
|
||||
'printer': report.printing_printer_id,
|
||||
},
|
||||
})
|
||||
|
||||
def test_onchange_printer_tray_id_empty(self):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -31,19 +30,22 @@ class TestPrintingPrinter(TransactionCase):
|
||||
'location': 'Location',
|
||||
'uri': 'URI',
|
||||
}
|
||||
self.report = self.env['ir.actions.report'].search([], limit=1)
|
||||
|
||||
def new_record(self):
|
||||
return self.Model.create(self.printer_vals)
|
||||
|
||||
def test_printing_options(self):
|
||||
""" It should generate the right options dictionnary """
|
||||
self.assertEqual(self.Model.print_options('report', 'raw'), {
|
||||
# TODO: None here used as report - tests here should be merged
|
||||
# with tests in test_printing_printer_tray from when modules merged
|
||||
self.assertEqual(self.Model.print_options(None, 'raw'), {
|
||||
'raw': 'True',
|
||||
})
|
||||
self.assertEqual(self.Model.print_options('report', 'pdf', 2), {
|
||||
self.assertEqual(self.Model.print_options(None, 'pdf', 2), {
|
||||
'copies': '2',
|
||||
})
|
||||
self.assertEqual(self.Model.print_options('report', 'raw', 2), {
|
||||
self.assertEqual(self.Model.print_options(None, 'raw', 2), {
|
||||
'raw': 'True',
|
||||
'copies': '2',
|
||||
})
|
||||
@@ -55,7 +57,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', b'content to print', 'pdf')
|
||||
printer.print_document(self.report, b'content to print', 'pdf')
|
||||
cups.Connection().printFile.assert_called_once_with(
|
||||
printer.system_name,
|
||||
file_name,
|
||||
@@ -72,14 +74,14 @@ class TestPrintingPrinter(TransactionCase):
|
||||
printer = self.new_record()
|
||||
with self.assertRaises(UserError):
|
||||
printer.print_document(
|
||||
'report_name', b'content to print', 'pdf')
|
||||
self.report, b'content to print', 'pdf')
|
||||
|
||||
@mock.patch('%s.cups' % server_model)
|
||||
def test_print_file(self, cups):
|
||||
""" It should print a file through CUPS """
|
||||
file_name = 'file_name'
|
||||
printer = self.new_record()
|
||||
printer.print_file(file_name, 'pdf')
|
||||
printer.print_file(file_name, report=self.report, format='pdf')
|
||||
cups.Connection().printFile.assert_called_once_with(
|
||||
printer.system_name,
|
||||
file_name,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -26,6 +25,7 @@ class TestPrintingPrinterWizard(TransactionCase):
|
||||
'printer-make-and-model': 'Make and Model',
|
||||
'printer-location': "location",
|
||||
'device-uri': 'URI',
|
||||
'printer-uri-supported': 'uri'
|
||||
}
|
||||
|
||||
def _record_vals(self, sys_name='sys_name'):
|
||||
@@ -52,6 +52,7 @@ class TestPrintingPrinterWizard(TransactionCase):
|
||||
cups.Connection().getPrinters.return_value = {
|
||||
'sys_name': self.printer_vals,
|
||||
}
|
||||
cups.Connection().getPPD3.return_value = (200, 0, '')
|
||||
self.Model.action_ok()
|
||||
cups.Connection().getPrinters.assert_called_once_with()
|
||||
|
||||
@@ -68,6 +69,7 @@ class TestPrintingPrinterWizard(TransactionCase):
|
||||
cups.Connection().getPrinters.return_value = {
|
||||
'sys_name': self.printer_vals,
|
||||
}
|
||||
cups.Connection().getPPD3.return_value = (200, 0, '')
|
||||
self.Model.action_ok()
|
||||
rec_id = self.env['printing.printer'].search([
|
||||
('system_name', '=', 'sys_name')
|
||||
@@ -89,6 +91,7 @@ class TestPrintingPrinterWizard(TransactionCase):
|
||||
cups.Connection().getPrinters.return_value = {
|
||||
'sys_name': self.printer_vals,
|
||||
}
|
||||
cups.Connection().getPPD3.return_value = (200, 0, '')
|
||||
self.env['printing.printer'].create(
|
||||
self._record_vals()
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 SYLEAM
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -47,12 +46,14 @@ class TestPrintingReportXmlAction(TransactionCase):
|
||||
self.assertEqual(xml_action.behaviour(), {
|
||||
'action': xml_action.action,
|
||||
'printer': xml_action.printer_id,
|
||||
'tray': False,
|
||||
})
|
||||
|
||||
xml_action = self.new_record({'printer_id': self.new_printer().id})
|
||||
self.assertEqual(xml_action.behaviour(), {
|
||||
'action': xml_action.action,
|
||||
'printer': xml_action.printer_id,
|
||||
'tray': False,
|
||||
})
|
||||
|
||||
self.assertEqual(self.Model.behaviour(), {})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="act_report_xml_view">
|
||||
<field name="name">ir.actions.report.printing</field>
|
||||
<field name="model">ir.actions.report</field>
|
||||
<field name="inherit_id" ref="base.act_report_xml_view" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='security']" position="before" >
|
||||
<page string="Print" name="print" >
|
||||
<group>
|
||||
<field name="property_printing_action_id"/>
|
||||
<field name="printing_printer_id"/>
|
||||
<field name="printer_tray_id"/>
|
||||
</group>
|
||||
|
||||
<separator string="Specific actions per user"/>
|
||||
<field name="printing_action_ids"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="act_report_xml_view">
|
||||
<field name="name">ir.actions.report.printing</field>
|
||||
<field name="model">ir.actions.report</field>
|
||||
<field name="inherit_id" ref="base.act_report_xml_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='security']" position="before">
|
||||
<page string="Print" name="print">
|
||||
<group>
|
||||
<field name="property_printing_action_id"/>
|
||||
<field name="printing_printer_id"/>
|
||||
<field name="printer_tray_id"/>
|
||||
</group>
|
||||
<separator string="Specific actions per user"/>
|
||||
<field name="printing_action_ids"/>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -7,23 +7,22 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Report Printing Actions">
|
||||
<group col="2">
|
||||
<field name="user_id"/>
|
||||
<field name="user_id" options="{'no_create': True}"/>
|
||||
<field name="action"/>
|
||||
<field name="printer_id" select="1"/>
|
||||
<field name="printer_id" options="{'no_create': True}"/>
|
||||
<field name="printer_tray_id"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="printing_report_xml_action_view_tree">
|
||||
<field name="name">printing.report.xml.action.tree</field>
|
||||
<field name="model">printing.report.xml.action</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Report Printing Actions">
|
||||
<field name="user_id"/>
|
||||
<tree string="Report Printing Actions" editable="bottom">
|
||||
<field name="user_id" options="{'no_create': True}"/>
|
||||
<field name="action"/>
|
||||
<field name="printer_id"/>
|
||||
<field name="printer_id" options="{'no_create': True}"/>
|
||||
<field name="printer_tray_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -62,9 +62,9 @@
|
||||
</record>
|
||||
|
||||
<menuitem name="Servers"
|
||||
sequence="10"
|
||||
id="printing_server_menu"
|
||||
parent="printing_menu"
|
||||
action="printing_server_action"/>
|
||||
sequence="10"
|
||||
id="printing_server_menu"
|
||||
parent="printing_menu"
|
||||
action="printing_server_action"/>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,32 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="view_users_form">
|
||||
<field name="name">res.users.form.printing.preferences</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='preferences']/ancestor::page" position="inside">
|
||||
<group string="Printing" name="printing">
|
||||
<field name="printing_action"/>
|
||||
<field name="printing_printer_id"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_users_form">
|
||||
<field name="name">res.users.form.printing.preferences</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='preferences']/ancestor::page" position="inside">
|
||||
<group string="Printing" name="printing">
|
||||
<field name="printing_action"/>
|
||||
<field name="printing_printer_id" options="{'no_create': True}"/>
|
||||
<field name="printer_tray_id" options="{'no_create': True}"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_users_form_simple_modif">
|
||||
<field name="name">res.users.form.printing</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
|
||||
<field name="arch" type="xml">
|
||||
<footer position="before">
|
||||
<group string="Printing" name="printing">
|
||||
<field name="printing_action"/>
|
||||
<field name="printing_printer_id"/>
|
||||
</group>
|
||||
</footer>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_users_form_simple_modif">
|
||||
<field name="name">res.users.form.printing</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
|
||||
<field name="arch" type="xml">
|
||||
<footer position="before">
|
||||
<group string="Printing" name="printing">
|
||||
<field name="printing_action" readonly="0"/>
|
||||
<field name="printing_printer_id" readonly="0" options="{'no_create': True}"/>
|
||||
<field name="printer_tray_id" readonly="0" options="{'no_create': True}"/>
|
||||
</group>
|
||||
</footer>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import printing_printer_update_wizard
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
|
||||
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
|
||||
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
|
||||
|
||||
Reference in New Issue
Block a user