mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[WIP] Commit before rebase on latest #109 for user and view updates
Migration of printer_tray to v11 and integration with base_report_to_printer
This commit is contained in:
@@ -8,18 +8,25 @@ Report To Printer
|
|||||||
|
|
||||||
This module allows users to send reports to a printer attached to the server.
|
This module allows users to send reports to a printer attached to the server.
|
||||||
|
|
||||||
|
|
||||||
It adds an optional behaviour on reports to send it directly to a printer.
|
It adds an optional behaviour on reports to send it directly to a printer.
|
||||||
|
|
||||||
* `Send to Client` is the default behaviour providing you a downloadable PDF
|
* `Send to Client` is the default behaviour providing you a downloadable PDF
|
||||||
* `Send to Printer` prints the report on selected printer
|
* `Send to Printer` prints the report on selected printer
|
||||||
|
|
||||||
|
It detects trays on printers installation plus permits to select the
|
||||||
|
paper source on which you want to print directly.
|
||||||
|
|
||||||
Report behaviour is defined by settings.
|
Report behaviour is defined by settings.
|
||||||
|
|
||||||
|
You will find this option on default user config, on default report
|
||||||
|
config and on specific config per user per report.
|
||||||
|
|
||||||
|
This allows you to dedicate a specific paper source for example for
|
||||||
|
preprinted paper such as payment slip.
|
||||||
|
|
||||||
Settings can be configured:
|
Settings can be configured:
|
||||||
|
|
||||||
* globaly
|
* globally
|
||||||
* per user
|
* per user
|
||||||
* per report
|
* per report
|
||||||
* per user and report
|
* per user and report
|
||||||
@@ -47,12 +54,17 @@ rights to give users the ability to view the print menu.
|
|||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
To show all available printers for your server, use the
|
* To update the CUPS printers in *Settings > Printing > Update Printers
|
||||||
`Settings/Configuration/Printing/Update Printers from CUPS` wizard.
|
from CUPS*
|
||||||
|
* If you want to print a report on a specific printer or tray, you can change
|
||||||
|
these in *Settings > Printing > Reports* to define default behaviour.
|
||||||
|
* If you want to print a report on a specific printer and/or tray for a user, you can
|
||||||
|
change these in *Settings > Printing > Reports* in
|
||||||
|
*Specific actions per user*
|
||||||
|
* Users may also select a default action, printer or tray in their preferences
|
||||||
|
|
||||||
|
When no tray is configured for a report and a user, the
|
||||||
Then go to the user profile and set the users printing action and default
|
default tray setup on the CUPS server is used.
|
||||||
printer.
|
|
||||||
|
|
||||||
Caveat
|
Caveat
|
||||||
------
|
------
|
||||||
@@ -62,7 +74,7 @@ displayed for the deprecated report types (RML, Webkit, ...).
|
|||||||
|
|
||||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
:target: https://runbot.odoo-community.org/runbot/144/9.0
|
:target: https://runbot.odoo-community.org/runbot/144/11.0
|
||||||
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
Known issues / Roadmap
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': "Report to printer",
|
'name': "Report to printer",
|
||||||
'version': '11.0.1.0.1',
|
'version': '11.0.2.0.0',
|
||||||
'category': 'Generic Modules/Base',
|
'category': 'Generic Modules/Base',
|
||||||
'author': "Agile Business Group & Domsense, Pegueroles SCP, NaN,"
|
'author': "Agile Business Group & Domsense, Pegueroles SCP, NaN,"
|
||||||
" LasLabs, Odoo Community Association (OCA)",
|
" LasLabs, Camptocamp, Odoo Community Association (OCA)",
|
||||||
'website': 'http://www.agilebg.com',
|
'website': 'http://www.agilebg.com',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
"depends": ['web'],
|
"depends": ['web'],
|
||||||
|
|||||||
@@ -6,4 +6,5 @@ from . import printing_job
|
|||||||
from . import printing_printer
|
from . import printing_printer
|
||||||
from . import printing_server
|
from . import printing_server
|
||||||
from . import printing_report_xml_action
|
from . import printing_report_xml_action
|
||||||
|
from . import printing_tray
|
||||||
from . import res_users
|
from . import res_users
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ class IrActionsReport(models.Model):
|
|||||||
comodel_name='printing.printer',
|
comodel_name='printing.printer',
|
||||||
string='Printer'
|
string='Printer'
|
||||||
)
|
)
|
||||||
|
printer_tray_id = fields.Many2one(
|
||||||
|
comodel_name='printing.tray',
|
||||||
|
string='Paper Source',
|
||||||
|
domain="[('printer_id', '=', printing_printer_id)]",
|
||||||
|
)
|
||||||
printing_action_ids = fields.One2many(
|
printing_action_ids = fields.One2many(
|
||||||
comodel_name='printing.report.xml.action',
|
comodel_name='printing.report.xml.action',
|
||||||
inverse_name='report_id',
|
inverse_name='report_id',
|
||||||
@@ -29,6 +34,11 @@ class IrActionsReport(models.Model):
|
|||||||
'user basis'
|
'user basis'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@api.onchange('printing_printer_id')
|
||||||
|
def onchange_printing_printer_id(self):
|
||||||
|
""" Reset the tray when the printer is changed """
|
||||||
|
self.printer_tray_id = False
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def print_action_for_report_name(self, report_name):
|
def print_action_for_report_name(self, report_name):
|
||||||
""" Returns if the action is a direct print or pdf
|
""" Returns if the action is a direct print or pdf
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
|
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
import errno
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from tempfile import mkstemp
|
from tempfile import mkstemp
|
||||||
|
|
||||||
@@ -17,6 +17,11 @@ from odoo import models, fields, api
|
|||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import cups
|
||||||
|
except ImportError:
|
||||||
|
_logger.debug('Cannot `import cups`.')
|
||||||
|
|
||||||
|
|
||||||
class PrintingPrinter(models.Model):
|
class PrintingPrinter(models.Model):
|
||||||
"""
|
"""
|
||||||
@@ -52,6 +57,55 @@ class PrintingPrinter(models.Model):
|
|||||||
model = fields.Char(readonly=True)
|
model = fields.Char(readonly=True)
|
||||||
location = fields.Char(readonly=True)
|
location = fields.Char(readonly=True)
|
||||||
uri = fields.Char(string='URI', readonly=True)
|
uri = fields.Char(string='URI', readonly=True)
|
||||||
|
tray_ids = fields.One2many(comodel_name='printing.tray',
|
||||||
|
inverse_name='printer_id',
|
||||||
|
string='Paper Sources')
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _prepare_update_from_cups(self, cups_connection, cups_printer):
|
||||||
|
vals = super(PrintingPrinter, self)._prepare_update_from_cups(
|
||||||
|
cups_connection, cups_printer)
|
||||||
|
|
||||||
|
printer_uri = cups_printer['printer-uri-supported']
|
||||||
|
printer_system_name = printer_uri[printer_uri.rfind('/') + 1:]
|
||||||
|
ppd_info = cups_connection.getPPD3(printer_system_name)
|
||||||
|
ppd_path = ppd_info[2]
|
||||||
|
if not ppd_path:
|
||||||
|
return vals
|
||||||
|
|
||||||
|
ppd = cups.PPD(ppd_path)
|
||||||
|
option = ppd.findOption('InputSlot')
|
||||||
|
try:
|
||||||
|
os.unlink(ppd_path)
|
||||||
|
except OSError as err:
|
||||||
|
# ENOENT means No such file or directory
|
||||||
|
# The file has already been deleted, we can continue the update
|
||||||
|
if err.errno != errno.ENOENT:
|
||||||
|
raise
|
||||||
|
if not option:
|
||||||
|
return vals
|
||||||
|
|
||||||
|
vals['tray_ids'] = []
|
||||||
|
cups_trays = {
|
||||||
|
tray_option['choice']: tray_option['text']
|
||||||
|
for tray_option in option.choices
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add new trays
|
||||||
|
vals['tray_ids'].extend([
|
||||||
|
(0, 0, {'name': text, 'system_name': choice})
|
||||||
|
for choice, text in cups_trays.items()
|
||||||
|
if choice not in self.tray_ids.mapped('system_name')
|
||||||
|
])
|
||||||
|
|
||||||
|
# Remove deleted trays
|
||||||
|
vals['tray_ids'].extend([
|
||||||
|
(2, tray.id)
|
||||||
|
for tray in self.tray_ids.filtered(
|
||||||
|
lambda record: record.system_name not in cups_trays.keys())
|
||||||
|
])
|
||||||
|
|
||||||
|
return vals
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _prepare_update_from_cups(self, cups_connection, cups_printer):
|
def _prepare_update_from_cups(self, cups_connection, cups_printer):
|
||||||
@@ -79,6 +133,25 @@ class PrintingPrinter(models.Model):
|
|||||||
options['raw'] = 'True'
|
options['raw'] = 'True'
|
||||||
if copies > 1:
|
if copies > 1:
|
||||||
options['copies'] = str(copies)
|
options['copies'] = str(copies)
|
||||||
|
if report is not None:
|
||||||
|
printing_act_obj = self.env['printing.report.xml.action']
|
||||||
|
if report.printer_tray_id:
|
||||||
|
tray = report.printer_tray_id
|
||||||
|
else:
|
||||||
|
# Retrieve user default values
|
||||||
|
tray = self.env.user.printer_tray_id
|
||||||
|
|
||||||
|
# Retrieve report-user specific values
|
||||||
|
action = printing_act_obj.search([
|
||||||
|
('report_id', '=', report.id),
|
||||||
|
('user_id', '=', self.env.uid),
|
||||||
|
('action', '!=', 'user_default'),
|
||||||
|
], limit=1)
|
||||||
|
if action.printer_tray_id:
|
||||||
|
tray = action.printer_tray_id
|
||||||
|
|
||||||
|
if tray:
|
||||||
|
options['InputSlot'] = str(tray.system_name)
|
||||||
return options
|
return options
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
@@ -28,6 +28,17 @@ class PrintingReportXmlAction(models.Model):
|
|||||||
printer_id = fields.Many2one(comodel_name='printing.printer',
|
printer_id = fields.Many2one(comodel_name='printing.printer',
|
||||||
string='Printer')
|
string='Printer')
|
||||||
|
|
||||||
|
printer_tray_id = fields.Many2one(
|
||||||
|
comodel_name='printing.tray',
|
||||||
|
string='Paper Source',
|
||||||
|
domain="[('printer_id', '=', printer_id)]",
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.onchange('printer_id')
|
||||||
|
def onchange_printer_id(self):
|
||||||
|
""" Reset the tray when the printer is changed """
|
||||||
|
self.printer_tray_id = False
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def behaviour(self):
|
def behaviour(self):
|
||||||
if not self:
|
if not self:
|
||||||
@@ -35,4 +46,5 @@ class PrintingReportXmlAction(models.Model):
|
|||||||
return {
|
return {
|
||||||
'action': self.action,
|
'action': self.action,
|
||||||
'printer': self.printer_id,
|
'printer': self.printer_id,
|
||||||
|
'tray': self.printer_tray_id.system_name
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,3 +26,14 @@ class ResUsers(models.Model):
|
|||||||
)
|
)
|
||||||
printing_printer_id = fields.Many2one(comodel_name='printing.printer',
|
printing_printer_id = fields.Many2one(comodel_name='printing.printer',
|
||||||
string='Default Printer')
|
string='Default Printer')
|
||||||
|
|
||||||
|
printer_tray_id = fields.Many2one(
|
||||||
|
comodel_name='printing.tray',
|
||||||
|
string='Default Printer Paper Source',
|
||||||
|
domain="[('printer_id', '=', printing_printer_id)]",
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.onchange('printing_printer_id')
|
||||||
|
def onchange_printing_printer_id(self):
|
||||||
|
""" Reset the tray when the printer is changed """
|
||||||
|
self.printer_tray_id = False
|
||||||
|
|||||||
@@ -1,96 +1,115 @@
|
|||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data noupdate="1">
|
<data noupdate="1">
|
||||||
<record id="printing_group_manager" model="res.groups">
|
<record id="printing_group_manager" model="res.groups">
|
||||||
<field name="name">Printing / Print Manager</field>
|
<field name="name">Printing / Print Manager</field>
|
||||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_group_user" model="res.groups">
|
<record id="printing_group_user" model="res.groups">
|
||||||
<field name="name">Printing / Print User</field>
|
<field name="name">Printing / Print User</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_server_group_manager" model="ir.model.access">
|
<record id="printing_server_group_manager" model="ir.model.access">
|
||||||
<field name="name">Printing Server Manager</field>
|
<field name="name">Printing Server Manager</field>
|
||||||
<field name="model_id" ref="model_printing_server"/>
|
<field name="model_id" ref="model_printing_server"/>
|
||||||
<field name="group_id" ref="printing_group_manager"/>
|
<field name="group_id" ref="printing_group_manager"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="1" name="perm_unlink"/>
|
<field eval="1" name="perm_unlink"/>
|
||||||
<field eval="1" name="perm_write"/>
|
<field eval="1" name="perm_write"/>
|
||||||
<field eval="1" name="perm_create"/>
|
<field eval="1" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_printer_group_manager" model="ir.model.access">
|
<record id="printing_printer_group_manager" model="ir.model.access">
|
||||||
<field name="name">Printing Printer Manager</field>
|
<field name="name">Printing Printer Manager</field>
|
||||||
<field name="model_id" ref="model_printing_printer"/>
|
<field name="model_id" ref="model_printing_printer"/>
|
||||||
<field name="group_id" ref="printing_group_manager"/>
|
<field name="group_id" ref="printing_group_manager"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="1" name="perm_unlink"/>
|
<field eval="1" name="perm_unlink"/>
|
||||||
<field eval="1" name="perm_write"/>
|
<field eval="1" name="perm_write"/>
|
||||||
<field eval="1" name="perm_create"/>
|
<field eval="1" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_action_group_manager" model="ir.model.access">
|
<record id="printing_action_group_manager" model="ir.model.access">
|
||||||
<field name="name">Printing Action Manager</field>
|
<field name="name">Printing Action Manager</field>
|
||||||
<field name="model_id" ref="model_printing_action"/>
|
<field name="model_id" ref="model_printing_action"/>
|
||||||
<field name="group_id" ref="printing_group_manager"/>
|
<field name="group_id" ref="printing_group_manager"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="1" name="perm_unlink"/>
|
<field eval="1" name="perm_unlink"/>
|
||||||
<field eval="1" name="perm_write"/>
|
<field eval="1" name="perm_write"/>
|
||||||
<field eval="1" name="perm_create"/>
|
<field eval="1" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_report_xml_action_group_manager" model="ir.model.access">
|
<record id="printing_report_xml_action_group_manager" model="ir.model.access">
|
||||||
<field name="name">Printing Report Xml Action Manager</field>
|
<field name="name">Printing Report Xml Action Manager</field>
|
||||||
<field name="model_id" ref="model_printing_report_xml_action"/>
|
<field name="model_id" ref="model_printing_report_xml_action"/>
|
||||||
<field name="group_id" ref="printing_group_manager"/>
|
<field name="group_id" ref="printing_group_manager"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="1" name="perm_unlink"/>
|
<field eval="1" name="perm_unlink"/>
|
||||||
<field eval="1" name="perm_write"/>
|
<field eval="1" name="perm_write"/>
|
||||||
<field eval="1" name="perm_create"/>
|
<field eval="1" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<record id="printing_server_group_user" model="ir.model.access">
|
<record id="printing_server_group_user" model="ir.model.access">
|
||||||
<field name="name">Printing Server User</field>
|
<field name="name">Printing Server User</field>
|
||||||
<field name="model_id" ref="model_printing_server"/>
|
<field name="model_id" ref="model_printing_server"/>
|
||||||
<field name="group_id" ref="printing_group_user"/>
|
<field name="group_id" ref="printing_group_user"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="0" name="perm_unlink"/>
|
<field eval="0" name="perm_unlink"/>
|
||||||
<field eval="0" name="perm_write"/>
|
<field eval="0" name="perm_write"/>
|
||||||
<field eval="0" name="perm_create"/>
|
<field eval="0" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_printer_group_user" model="ir.model.access">
|
<record id="printing_printer_group_user" model="ir.model.access">
|
||||||
<field name="name">Printing Printer User</field>
|
<field name="name">Printing Printer User</field>
|
||||||
<field name="model_id" ref="model_printing_printer"/>
|
<field name="model_id" ref="model_printing_printer"/>
|
||||||
<field name="group_id" ref="printing_group_user"/>
|
<field name="group_id" ref="printing_group_user"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="0" name="perm_unlink"/>
|
<field eval="0" name="perm_unlink"/>
|
||||||
<field eval="0" name="perm_write"/>
|
<field eval="0" name="perm_write"/>
|
||||||
<field eval="0" name="perm_create"/>
|
<field eval="0" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_job_group_user" model="ir.model.access">
|
<record id="printing_job_group_user" model="ir.model.access">
|
||||||
<field name="name">Printing Job User</field>
|
<field name="name">Printing Job User</field>
|
||||||
<field name="model_id" ref="model_printing_job"/>
|
<field name="model_id" ref="model_printing_job"/>
|
||||||
<field name="group_id" ref="printing_group_user"/>
|
<field name="group_id" ref="printing_group_user"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="0" name="perm_unlink"/>
|
<field eval="0" name="perm_unlink"/>
|
||||||
<field eval="0" name="perm_write"/>
|
<field eval="0" name="perm_write"/>
|
||||||
<field eval="0" name="perm_create"/>
|
<field eval="0" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_action_group_user" model="ir.model.access">
|
<record id="printing_action_group_user" model="ir.model.access">
|
||||||
<field name="name">Printing Action User</field>
|
<field name="name">Printing Action User</field>
|
||||||
<field name="model_id" ref="model_printing_action"/>
|
<field name="model_id" ref="model_printing_action"/>
|
||||||
<field name="group_id" ref="printing_group_user"/>
|
<field name="group_id" ref="printing_group_user"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="0" name="perm_unlink"/>
|
<field eval="0" name="perm_unlink"/>
|
||||||
<field eval="0" name="perm_write"/>
|
<field eval="0" name="perm_write"/>
|
||||||
<field eval="0" name="perm_create"/>
|
<field eval="0" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="printing_report_xml_action_group_user" model="ir.model.access">
|
<record id="printing_report_xml_action_group_user" model="ir.model.access">
|
||||||
<field name="name">Printing Report Xml Action User</field>
|
<field name="name">Printing Report Xml Action User</field>
|
||||||
<field name="model_id" ref="model_printing_report_xml_action"/>
|
<field name="model_id" ref="model_printing_report_xml_action"/>
|
||||||
<field name="group_id" ref="printing_group_user"/>
|
<field name="group_id" ref="printing_group_user"/>
|
||||||
<field eval="1" name="perm_read"/>
|
<field eval="1" name="perm_read"/>
|
||||||
<field eval="0" name="perm_unlink"/>
|
<field eval="0" name="perm_unlink"/>
|
||||||
<field eval="0" name="perm_write"/>
|
<field eval="0" name="perm_write"/>
|
||||||
<field eval="0" name="perm_create"/>
|
<field eval="0" name="perm_create"/>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
<!--Ported from printing_tray -->
|
||||||
|
<record id="access_printing_tray_all" model="ir.model.access">
|
||||||
|
<field name="name">Printing Tray User</field>
|
||||||
|
<field name="model_id" ref="model_printing_tray"/>
|
||||||
|
<field name="group_id" ref="printing_group_user"/>
|
||||||
|
<field eval="1" name="perm_read"/>
|
||||||
|
<field eval="0" name="perm_unlink"/>
|
||||||
|
<field eval="0" name="perm_write"/>
|
||||||
|
<field eval="0" name="perm_create"/>
|
||||||
|
</record>
|
||||||
|
<record id="access_printing_tray_operator" model="ir.model.access">
|
||||||
|
<field name="name">Printing Tray User</field>
|
||||||
|
<field name="model_id" ref="model_printing_tray"/>
|
||||||
|
<field name="group_id" ref="printing_group_manager"/>
|
||||||
|
<field eval="1" name="perm_read"/>
|
||||||
|
<field eval="1" name="perm_unlink"/>
|
||||||
|
<field eval="1" name="perm_write"/>
|
||||||
|
<field eval="1" name="perm_create"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
from . import test_printing_job
|
from . import test_printing_job
|
||||||
from . import test_printing_printer
|
from . import test_printing_printer
|
||||||
|
from . import test_printing_printer_tray
|
||||||
from . import test_printing_server
|
from . import test_printing_server
|
||||||
|
from . import test_printing_tray
|
||||||
from . import test_report
|
from . import test_report
|
||||||
from . import test_res_users
|
from . import test_res_users
|
||||||
from . import test_ir_actions_report
|
from . import test_ir_actions_report
|
||||||
|
|||||||
@@ -204,3 +204,34 @@ class TestIrActionsReportXml(TransactionCase):
|
|||||||
'printer': report.printing_printer_id,
|
'printer': report.printing_printer_id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def test_onchange_printer_tray_id_empty(self):
|
||||||
|
action = self.env['ir.actions.report'].new(
|
||||||
|
{'printer_tray_id': False})
|
||||||
|
action.onchange_printing_printer_id()
|
||||||
|
self.assertFalse(action.printer_tray_id)
|
||||||
|
|
||||||
|
def test_onchange_printer_tray_id_not_empty(self):
|
||||||
|
server = self.env['printing.server'].create({})
|
||||||
|
printer = self.env['printing.printer'].create({
|
||||||
|
'name': 'Printer',
|
||||||
|
'server_id': server.id,
|
||||||
|
'system_name': 'Sys Name',
|
||||||
|
'default': True,
|
||||||
|
'status': 'unknown',
|
||||||
|
'status_message': 'Msg',
|
||||||
|
'model': 'res.users',
|
||||||
|
'location': 'Location',
|
||||||
|
'uri': 'URI',
|
||||||
|
})
|
||||||
|
tray = self.env['printing.tray'].create({
|
||||||
|
'name': 'Tray',
|
||||||
|
'system_name': 'TrayName',
|
||||||
|
'printer_id': printer.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
action = self.env['ir.actions.report'].new(
|
||||||
|
{'printer_tray_id': tray.id})
|
||||||
|
self.assertEqual(action.printer_tray_id, tray)
|
||||||
|
action.onchange_printing_printer_id()
|
||||||
|
self.assertFalse(action.printer_tray_id)
|
||||||
|
|||||||
@@ -56,3 +56,34 @@ class TestPrintingReportXmlAction(TransactionCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
self.assertEqual(self.Model.behaviour(), {})
|
self.assertEqual(self.Model.behaviour(), {})
|
||||||
|
|
||||||
|
def test_onchange_printer_tray_id_empty(self):
|
||||||
|
action = self.env['printing.report.xml.action'].new(
|
||||||
|
{'printer_tray_id': False})
|
||||||
|
action.onchange_printer_id()
|
||||||
|
self.assertFalse(action.printer_tray_id)
|
||||||
|
|
||||||
|
def test_onchange_printer_tray_id_not_empty(self):
|
||||||
|
server = self.env['printing.server'].create({})
|
||||||
|
printer = self.env['printing.printer'].create({
|
||||||
|
'name': 'Printer',
|
||||||
|
'server_id': server.id,
|
||||||
|
'system_name': 'Sys Name',
|
||||||
|
'default': True,
|
||||||
|
'status': 'unknown',
|
||||||
|
'status_message': 'Msg',
|
||||||
|
'model': 'res.users',
|
||||||
|
'location': 'Location',
|
||||||
|
'uri': 'URI',
|
||||||
|
})
|
||||||
|
tray = self.env['printing.tray'].create({
|
||||||
|
'name': 'Tray',
|
||||||
|
'system_name': 'TrayName',
|
||||||
|
'printer_id': printer.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
action = self.env['printing.report.xml.action'].new(
|
||||||
|
{'printer_tray_id': tray.id})
|
||||||
|
self.assertEqual(action.printer_tray_id, tray)
|
||||||
|
action.onchange_printer_id()
|
||||||
|
self.assertFalse(action.printer_tray_id)
|
||||||
|
|||||||
@@ -26,3 +26,34 @@ class TestResUsers(TransactionCase):
|
|||||||
""" It should still contain other valid keys """
|
""" It should still contain other valid keys """
|
||||||
self.user_vals['printing_action'] = 'server'
|
self.user_vals['printing_action'] = 'server'
|
||||||
self.assertTrue(self.new_record())
|
self.assertTrue(self.new_record())
|
||||||
|
|
||||||
|
def test_onchange_printer_tray_id_empty(self):
|
||||||
|
user = self.env['res.users'].new(
|
||||||
|
{'printer_tray_id': False})
|
||||||
|
user.onchange_printing_printer_id()
|
||||||
|
self.assertFalse(user.printer_tray_id)
|
||||||
|
|
||||||
|
def test_onchange_printer_tray_id_not_empty(self):
|
||||||
|
server = self.env['printing.server'].create({})
|
||||||
|
printer = self.env['printing.printer'].create({
|
||||||
|
'name': 'Printer',
|
||||||
|
'server_id': server.id,
|
||||||
|
'system_name': 'Sys Name',
|
||||||
|
'default': True,
|
||||||
|
'status': 'unknown',
|
||||||
|
'status_message': 'Msg',
|
||||||
|
'model': 'res.users',
|
||||||
|
'location': 'Location',
|
||||||
|
'uri': 'URI',
|
||||||
|
})
|
||||||
|
tray = self.env['printing.tray'].create({
|
||||||
|
'name': 'Tray',
|
||||||
|
'system_name': 'TrayName',
|
||||||
|
'printer_id': printer.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
user = self.env['res.users'].new(
|
||||||
|
{'printer_tray_id': tray.id})
|
||||||
|
self.assertEqual(user.printer_tray_id, tray)
|
||||||
|
user.onchange_printing_printer_id()
|
||||||
|
self.assertFalse(user.printer_tray_id)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<group>
|
<group>
|
||||||
<field name="property_printing_action_id"/>
|
<field name="property_printing_action_id"/>
|
||||||
<field name="printing_printer_id"/>
|
<field name="printing_printer_id"/>
|
||||||
|
<field name="printer_tray_id"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<separator string="Specific actions per user"/>
|
<separator string="Specific actions per user"/>
|
||||||
|
|||||||
@@ -23,22 +23,32 @@
|
|||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group name="name">
|
||||||
<field name="system_name"/>
|
<field name="system_name"/>
|
||||||
</group>
|
</group>
|
||||||
<group col="4" colspan="4">
|
<group col="4" colspan="4" name="default">
|
||||||
<field name="default"/>
|
<field name="default"/>
|
||||||
<button name="set_default" string="Set Default" type="object" attrs="{'invisible': [('default','=', True)]}"/>
|
<button name="set_default" string="Set Default" type="object" attrs="{'invisible': [('default','=', True)]}"/>
|
||||||
<button name="unset_default" string="Unset Default" type="object" attrs="{'invisible': [('default','=', False)]}"/>
|
<button name="unset_default" string="Unset Default" type="object" attrs="{'invisible': [('default','=', False)]}"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group name="details">
|
||||||
<field name="uri"/>
|
<field name="uri"/>
|
||||||
<field name="model"/>
|
<field name="model"/>
|
||||||
<field name="location"/>
|
<field name="location"/>
|
||||||
<field name="status"/>
|
<field name="status"/>
|
||||||
<field name="status_message"/>
|
<field name="status_message"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group string="Trays" name="trays">
|
||||||
|
<field name="tray_ids" nolabel="1">
|
||||||
|
<form>
|
||||||
|
<group name="name_fields">
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="system_name"/>
|
||||||
|
</group>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</group>
|
||||||
|
<group name="jobs">
|
||||||
<separator string="Jobs" colspan="2"/>
|
<separator string="Jobs" colspan="2"/>
|
||||||
<field name="job_ids" nolabel="1"/>
|
<field name="job_ids" nolabel="1"/>
|
||||||
</group>
|
</group>
|
||||||
|
|||||||
@@ -1,35 +1,38 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="printing_report_xml_action_view_form">
|
<record model="ir.ui.view" id="printing_report_xml_action_view_form">
|
||||||
<field name="name">printing.report.xml.action.form</field>
|
<field name="name">printing.report.xml.action.form</field>
|
||||||
<field name="model">printing.report.xml.action</field>
|
<field name="model">printing.report.xml.action</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Report Printing Actions">
|
<form string="Report Printing Actions">
|
||||||
<group col="2">
|
<group col="2">
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
<field name="action"/>
|
<field name="action"/>
|
||||||
<field name="printer_id" select="1"/>
|
<field name="printer_id" select="1"/>
|
||||||
</group>
|
<field name="printer_tray_id"/>
|
||||||
</form>
|
</group>
|
||||||
</field>
|
</form>
|
||||||
</record>
|
</field>
|
||||||
<record model="ir.ui.view" id="printing_report_xml_action_view_tree">
|
</record>
|
||||||
<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"/>
|
|
||||||
<field name="action" />
|
|
||||||
<field name="printer_id" />
|
|
||||||
</tree>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- Add a shorcut to "Actions/Report" in the Printing menu -->
|
<record model="ir.ui.view" id="printing_report_xml_action_view_tree">
|
||||||
<menuitem id="printing_report_xml_action_menu"
|
<field name="name">printing.report.xml.action.tree</field>
|
||||||
sequence="30"
|
<field name="model">printing.report.xml.action</field>
|
||||||
parent="printing_menu"
|
<field name="arch" type="xml">
|
||||||
action="base.ir_action_report"/>
|
<tree string="Report Printing Actions">
|
||||||
|
<field name="user_id"/>
|
||||||
|
<field name="action"/>
|
||||||
|
<field name="printer_id"/>
|
||||||
|
<field name="printer_tray_id"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Add a shorcut to "Actions/Report" in the Printing menu -->
|
||||||
|
<menuitem id="printing_report_xml_action_menu"
|
||||||
|
sequence="30"
|
||||||
|
parent="printing_menu"
|
||||||
|
action="base.ir_action_report"/>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
|
||||||
:alt: License: AGPL-3
|
|
||||||
|
|
||||||
========================================
|
|
||||||
Report to printer - Paper tray selection
|
|
||||||
========================================
|
|
||||||
|
|
||||||
Extends the module **Report to printer** (``base_report_to_printer``)
|
|
||||||
to add the printers trays.
|
|
||||||
|
|
||||||
It detects trays on printers installation plus permits to select the
|
|
||||||
paper source on which you want to print directly.
|
|
||||||
|
|
||||||
You will find this option on default user config, on default report
|
|
||||||
config and on specific config per user per report.
|
|
||||||
|
|
||||||
This allows you to dedicate a specific paper source for example for
|
|
||||||
preprinted paper such as payment slip.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
Considering that you already use the module **Report to printer**, you
|
|
||||||
just have to install this extension.
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
=============
|
|
||||||
|
|
||||||
To configure this module, you need to:
|
|
||||||
|
|
||||||
* Update the CUPS printers in *Settings > Printing > Update Printers
|
|
||||||
from CUPS*
|
|
||||||
* If you want to print a report on a specific tray, you can change
|
|
||||||
their "Paper Source" in *Settings > Printing > Reports*
|
|
||||||
* If you want to print a report on a specific tray for a user, you can
|
|
||||||
change their "Paper Source" in *Settings > Printing > Reports* in
|
|
||||||
*Specific actions per user*
|
|
||||||
* Users may also select a default tray in their preferences
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
|
|
||||||
There is no special usage, once configured, reports are printed in the
|
|
||||||
select tray. When no tray is configured for a report and a user, the
|
|
||||||
default tray setup on the CUPS server is used.
|
|
||||||
|
|
||||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
|
||||||
:alt: Try me on Runbot
|
|
||||||
:target: https://runbot.odoo-community.org/runbot/144/10.0
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Bug Tracker
|
|
||||||
===========
|
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues
|
|
||||||
<https://github.com/OCA/report-print-send/issues>`_. In case of trouble, please
|
|
||||||
check there if your issue has already been reported. If you spotted it first,
|
|
||||||
help us smashing it by providing a detailed and welcomed feedback.
|
|
||||||
|
|
||||||
Credits
|
|
||||||
=======
|
|
||||||
|
|
||||||
Contributors
|
|
||||||
------------
|
|
||||||
|
|
||||||
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
|
|
||||||
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
|
||||||
|
|
||||||
Maintainer
|
|
||||||
----------
|
|
||||||
|
|
||||||
.. image:: https://odoo-community.org/logo.png
|
|
||||||
:alt: Odoo Community Association
|
|
||||||
:target: https://odoo-community.org
|
|
||||||
|
|
||||||
This module is maintained by the OCA.
|
|
||||||
|
|
||||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|
||||||
mission is to support the collaborative development of Odoo features and
|
|
||||||
promote its widespread use.
|
|
||||||
|
|
||||||
To contribute to this module, please visit https://odoo-community.org.
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from . import models
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
{
|
|
||||||
'name': 'Report to printer - Paper tray selection',
|
|
||||||
'version': '11.0.1.0.0',
|
|
||||||
'category': 'Printer',
|
|
||||||
'author': "Camptocamp, Odoo Community Association (OCA)",
|
|
||||||
'maintainer': 'Camptocamp',
|
|
||||||
'website': 'http://www.camptocamp.com/',
|
|
||||||
'license': 'AGPL-3',
|
|
||||||
'depends': [
|
|
||||||
'base_report_to_printer',
|
|
||||||
],
|
|
||||||
'data': [
|
|
||||||
'views/res_users.xml',
|
|
||||||
'views/ir_actions_report.xml',
|
|
||||||
'views/printing_printer.xml',
|
|
||||||
'views/printing_report_xml_action.xml',
|
|
||||||
'security/ir.model.access.csv',
|
|
||||||
],
|
|
||||||
'external_dependencies': {
|
|
||||||
'python': ['cups'],
|
|
||||||
},
|
|
||||||
'installable': True,
|
|
||||||
'application': False,
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from . import ir_actions_report
|
|
||||||
from . import printing_tray
|
|
||||||
from . import printing_printer
|
|
||||||
from . import res_users
|
|
||||||
from . import printing_report_xml_action
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import api, fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class IrActionsReport(models.Model):
|
|
||||||
_inherit = 'ir.actions.report'
|
|
||||||
|
|
||||||
printer_tray_id = fields.Many2one(
|
|
||||||
comodel_name='printing.tray',
|
|
||||||
string='Paper Source',
|
|
||||||
domain="[('printer_id', '=', printing_printer_id)]",
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.onchange('printing_printer_id')
|
|
||||||
def onchange_printing_printer_id(self):
|
|
||||||
""" Reset the tray when the printer is changed """
|
|
||||||
self.printer_tray_id = False
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
import errno
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
|
|
||||||
from odoo import api, fields, models
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
try:
|
|
||||||
import cups
|
|
||||||
except ImportError:
|
|
||||||
_logger.debug('Cannot `import cups`.')
|
|
||||||
|
|
||||||
|
|
||||||
class PrintingPrinter(models.Model):
|
|
||||||
_inherit = 'printing.printer'
|
|
||||||
|
|
||||||
tray_ids = fields.One2many(comodel_name='printing.tray',
|
|
||||||
inverse_name='printer_id',
|
|
||||||
string='Paper Sources')
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _prepare_update_from_cups(self, cups_connection, cups_printer):
|
|
||||||
vals = super(PrintingPrinter, self)._prepare_update_from_cups(
|
|
||||||
cups_connection, cups_printer)
|
|
||||||
|
|
||||||
printer_uri = cups_printer['printer-uri-supported']
|
|
||||||
printer_system_name = printer_uri[printer_uri.rfind('/') + 1:]
|
|
||||||
ppd_info = cups_connection.getPPD3(printer_system_name)
|
|
||||||
ppd_path = ppd_info[2]
|
|
||||||
if not ppd_path:
|
|
||||||
return vals
|
|
||||||
|
|
||||||
ppd = cups.PPD(ppd_path)
|
|
||||||
option = ppd.findOption('InputSlot')
|
|
||||||
try:
|
|
||||||
os.unlink(ppd_path)
|
|
||||||
except OSError as err:
|
|
||||||
# ENOENT means No such file or directory
|
|
||||||
# The file has already been deleted, we can continue the update
|
|
||||||
if err.errno != errno.ENOENT:
|
|
||||||
raise
|
|
||||||
if not option:
|
|
||||||
return vals
|
|
||||||
|
|
||||||
vals['tray_ids'] = []
|
|
||||||
cups_trays = {
|
|
||||||
tray_option['choice']: tray_option['text']
|
|
||||||
for tray_option in option.choices
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add new trays
|
|
||||||
vals['tray_ids'].extend([
|
|
||||||
(0, 0, {'name': text, 'system_name': choice})
|
|
||||||
for choice, text in cups_trays.items()
|
|
||||||
if choice not in self.tray_ids.mapped('system_name')
|
|
||||||
])
|
|
||||||
|
|
||||||
# Remove deleted trays
|
|
||||||
vals['tray_ids'].extend([
|
|
||||||
(2, tray.id)
|
|
||||||
for tray in self.tray_ids.filtered(
|
|
||||||
lambda record: record.system_name not in cups_trays.keys())
|
|
||||||
])
|
|
||||||
|
|
||||||
return vals
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def print_options(self, report=None, format=None, copies=1):
|
|
||||||
""" Hook to define Tray """
|
|
||||||
printing_act_obj = self.env['printing.report.xml.action']
|
|
||||||
options = super(PrintingPrinter, self).print_options(report, format)
|
|
||||||
|
|
||||||
if report is not None:
|
|
||||||
# Retrieve report default values
|
|
||||||
if report.printer_tray_id:
|
|
||||||
tray = report.printer_tray_id
|
|
||||||
else:
|
|
||||||
# Retrieve user default values
|
|
||||||
tray = self.env.user.printer_tray_id
|
|
||||||
|
|
||||||
# Retrieve report-user specific values
|
|
||||||
action = printing_act_obj.search([
|
|
||||||
('report_id', '=', report.id),
|
|
||||||
('user_id', '=', self.env.uid),
|
|
||||||
('action', '!=', 'user_default'),
|
|
||||||
], limit=1)
|
|
||||||
if action.printer_tray_id:
|
|
||||||
tray = action.printer_tray_id
|
|
||||||
|
|
||||||
if tray:
|
|
||||||
options['InputSlot'] = str(tray.system_name)
|
|
||||||
|
|
||||||
return options
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import api, fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class PrintingReportXMLAction(models.Model):
|
|
||||||
_inherit = 'printing.report.xml.action'
|
|
||||||
|
|
||||||
printer_tray_id = fields.Many2one(
|
|
||||||
comodel_name='printing.tray',
|
|
||||||
string='Paper Source',
|
|
||||||
domain="[('printer_id', '=', printer_id)]",
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def behaviour(self):
|
|
||||||
self.ensure_one()
|
|
||||||
res = super(PrintingReportXMLAction, self).behaviour()
|
|
||||||
res['tray'] = self.printer_tray_id.system_name
|
|
||||||
return res
|
|
||||||
|
|
||||||
@api.onchange('printer_id')
|
|
||||||
def onchange_printer_id(self):
|
|
||||||
""" Reset the tray when the printer is changed """
|
|
||||||
self.printer_tray_id = False
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright (C) 2013-2014 Camptocamp (<http://www.camptocamp.com>)
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import api, fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class ResUsers(models.Model):
|
|
||||||
_inherit = "res.users"
|
|
||||||
|
|
||||||
printer_tray_id = fields.Many2one(
|
|
||||||
comodel_name='printing.tray',
|
|
||||||
string='Default Printer Paper Source',
|
|
||||||
domain="[('printer_id', '=', printing_printer_id)]",
|
|
||||||
)
|
|
||||||
|
|
||||||
@api.onchange('printing_printer_id')
|
|
||||||
def onchange_printing_printer_id(self):
|
|
||||||
""" Reset the tray when the printer is changed """
|
|
||||||
self.printer_tray_id = False
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
|
|
||||||
access_printing_tray_all,printing_tray all,model_printing_tray,base_report_to_printer.printing_group_user,1,0,0,0
|
|
||||||
access_printing_tray_operator,printing_tray operator,model_printing_tray,base_report_to_printer.printing_group_manager,1,1,1,1
|
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2016 LasLabs Inc.
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
||||||
|
|
||||||
from . import test_ir_actions_report
|
|
||||||
from . import test_printing_printer
|
|
||||||
from . import test_printing_report_xml_action
|
|
||||||
from . import test_printing_tray
|
|
||||||
from . import test_res_users
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2017 SYLEAM Info Services
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.tests.common import TransactionCase
|
|
||||||
|
|
||||||
|
|
||||||
class TestIrActionsReportXml(TransactionCase):
|
|
||||||
def test_onchange_printer_tray_id_empty(self):
|
|
||||||
action = self.env['ir.actions.report'].new(
|
|
||||||
{'printer_tray_id': False})
|
|
||||||
action.onchange_printing_printer_id()
|
|
||||||
self.assertFalse(action.printer_tray_id)
|
|
||||||
|
|
||||||
def test_onchange_printer_tray_id_not_empty(self):
|
|
||||||
server = self.env['printing.server'].create({})
|
|
||||||
printer = self.env['printing.printer'].create({
|
|
||||||
'name': 'Printer',
|
|
||||||
'server_id': server.id,
|
|
||||||
'system_name': 'Sys Name',
|
|
||||||
'default': True,
|
|
||||||
'status': 'unknown',
|
|
||||||
'status_message': 'Msg',
|
|
||||||
'model': 'res.users',
|
|
||||||
'location': 'Location',
|
|
||||||
'uri': 'URI',
|
|
||||||
})
|
|
||||||
tray = self.env['printing.tray'].create({
|
|
||||||
'name': 'Tray',
|
|
||||||
'system_name': 'TrayName',
|
|
||||||
'printer_id': printer.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
action = self.env['ir.actions.report'].new(
|
|
||||||
{'printer_tray_id': tray.id})
|
|
||||||
self.assertEqual(action.printer_tray_id, tray)
|
|
||||||
action.onchange_printing_printer_id()
|
|
||||||
self.assertFalse(action.printer_tray_id)
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2017 SYLEAM Info Services
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.tests.common import TransactionCase
|
|
||||||
|
|
||||||
|
|
||||||
class TestPrintingReportXmlAction(TransactionCase):
|
|
||||||
def test_onchange_printer_tray_id_empty(self):
|
|
||||||
action = self.env['printing.report.xml.action'].new(
|
|
||||||
{'printer_tray_id': False})
|
|
||||||
action.onchange_printer_id()
|
|
||||||
self.assertFalse(action.printer_tray_id)
|
|
||||||
|
|
||||||
def test_onchange_printer_tray_id_not_empty(self):
|
|
||||||
server = self.env['printing.server'].create({})
|
|
||||||
printer = self.env['printing.printer'].create({
|
|
||||||
'name': 'Printer',
|
|
||||||
'server_id': server.id,
|
|
||||||
'system_name': 'Sys Name',
|
|
||||||
'default': True,
|
|
||||||
'status': 'unknown',
|
|
||||||
'status_message': 'Msg',
|
|
||||||
'model': 'res.users',
|
|
||||||
'location': 'Location',
|
|
||||||
'uri': 'URI',
|
|
||||||
})
|
|
||||||
tray = self.env['printing.tray'].create({
|
|
||||||
'name': 'Tray',
|
|
||||||
'system_name': 'TrayName',
|
|
||||||
'printer_id': printer.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
action = self.env['printing.report.xml.action'].new(
|
|
||||||
{'printer_tray_id': tray.id})
|
|
||||||
self.assertEqual(action.printer_tray_id, tray)
|
|
||||||
action.onchange_printer_id()
|
|
||||||
self.assertFalse(action.printer_tray_id)
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2017 SYLEAM Info Services
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo.tests.common import TransactionCase
|
|
||||||
|
|
||||||
|
|
||||||
class TestResUsers(TransactionCase):
|
|
||||||
def test_onchange_printer_tray_id_empty(self):
|
|
||||||
user = self.env['res.users'].new(
|
|
||||||
{'printer_tray_id': False})
|
|
||||||
user.onchange_printing_printer_id()
|
|
||||||
self.assertFalse(user.printer_tray_id)
|
|
||||||
|
|
||||||
def test_onchange_printer_tray_id_not_empty(self):
|
|
||||||
server = self.env['printing.server'].create({})
|
|
||||||
printer = self.env['printing.printer'].create({
|
|
||||||
'name': 'Printer',
|
|
||||||
'server_id': server.id,
|
|
||||||
'system_name': 'Sys Name',
|
|
||||||
'default': True,
|
|
||||||
'status': 'unknown',
|
|
||||||
'status_message': 'Msg',
|
|
||||||
'model': 'res.users',
|
|
||||||
'location': 'Location',
|
|
||||||
'uri': 'URI',
|
|
||||||
})
|
|
||||||
tray = self.env['printing.tray'].create({
|
|
||||||
'name': 'Tray',
|
|
||||||
'system_name': 'TrayName',
|
|
||||||
'printer_id': printer.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
user = self.env['res.users'].new(
|
|
||||||
{'printer_tray_id': tray.id})
|
|
||||||
self.assertEqual(user.printer_tray_id, tray)
|
|
||||||
user.onchange_printing_printer_id()
|
|
||||||
self.assertFalse(user.printer_tray_id)
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<!-- ir.report form view -->
|
|
||||||
<record model="ir.ui.view" id="act_report_xml_view">
|
|
||||||
<field name="name">ir.actions.report.xml.add.printer.tray</field>
|
|
||||||
<field name="model">ir.actions.report</field>
|
|
||||||
<field name="inherit_id" ref="base_report_to_printer.act_report_xml_view"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="printing_printer_id" position="after">
|
|
||||||
<field name="printer_tray_id"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<record model="ir.ui.view" id="printing_printer_view_form">
|
|
||||||
<field name="name">printing.printer.form</field>
|
|
||||||
<field name="model">printing.printer</field>
|
|
||||||
<field name="inherit_id" ref="base_report_to_printer.printing_printer_view_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//sheet/group[3]" position="after">
|
|
||||||
<group string="Trays" name="trays">
|
|
||||||
<field name="tray_ids" nolabel="1">
|
|
||||||
<form>
|
|
||||||
<group name="name_fields">
|
|
||||||
<field name="name"/>
|
|
||||||
<field name="system_name"/>
|
|
||||||
</group>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</group>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<record id="printing_report_xml_action_view_form" model="ir.ui.view">
|
|
||||||
<field name="name">printing.report.xml.action.form</field>
|
|
||||||
<field name="model">printing.report.xml.action</field>
|
|
||||||
<field name="inherit_id" ref="base_report_to_printer.printing_report_xml_action_view_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='printer_id']" position="after">
|
|
||||||
<field name="printer_tray_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="printing_report_xml_action_view_tree" model="ir.ui.view">
|
|
||||||
<field name="name">printing.report.xml.action.form</field>
|
|
||||||
<field name="model">printing.report.xml.action</field>
|
|
||||||
<field name="inherit_id" ref="base_report_to_printer.printing_report_xml_action_view_tree"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='printer_id']" position="after">
|
|
||||||
<field name="printer_tray_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
Reference in New Issue
Block a user