mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
print_options is now in printing, new api for ir.actions.report.xml
This commit is contained in:
committed by
Graeme Gellatly
parent
a38e724c88
commit
a7aa6cbccb
@@ -18,46 +18,15 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from openerp.osv import orm, fields
|
from openerp import models, fields
|
||||||
|
|
||||||
|
|
||||||
class ReportXML(orm.Model):
|
class IrActionsReportXml(models.Model):
|
||||||
|
|
||||||
_inherit = 'ir.actions.report.xml'
|
_inherit = 'ir.actions.report.xml'
|
||||||
|
|
||||||
_columns = {
|
printer_tray_id = fields.Many2one(
|
||||||
'printer_tray_id': fields.many2one(
|
comodel_name='printing.tray',
|
||||||
'printing.tray', 'Paper Source',
|
string='Paper Source',
|
||||||
domain="[('printer_id', '=', printing_printer_id)]"),
|
domain="[('printer_id', '=', printing_printer_id)]",
|
||||||
}
|
)
|
||||||
|
|
||||||
def set_print_options(self, cr, uid, report_id, format, context=None):
|
|
||||||
"""
|
|
||||||
Hook to define Tray
|
|
||||||
"""
|
|
||||||
printing_act_obj = self.pool.get('printing.report.xml.action')
|
|
||||||
options = super(ReportXML, self).set_print_options(cr, uid, report_id, format, context=context)
|
|
||||||
|
|
||||||
# Retrieve user default values
|
|
||||||
user = self.pool.get('res.users').browse(cr, uid, context)
|
|
||||||
tray = user.printer_tray_id
|
|
||||||
report = self.browse(cr, uid, report_id, context=context)
|
|
||||||
|
|
||||||
# Retrieve report default values
|
|
||||||
if report.printer_tray_id:
|
|
||||||
tray = report.printer_tray_id
|
|
||||||
|
|
||||||
# Retrieve report-user specific values
|
|
||||||
act_ids = printing_act_obj.search(
|
|
||||||
cr, uid,
|
|
||||||
[('report_id', '=', report.id),
|
|
||||||
('user_id', '=', uid),
|
|
||||||
('action', '!=', 'user_default')], context=context)
|
|
||||||
if act_ids:
|
|
||||||
user_action = printing_act_obj.browse(cr, uid, act_ids[0], context=context)
|
|
||||||
if user_action.tray_id:
|
|
||||||
tray = user_action.tray_id
|
|
||||||
|
|
||||||
if tray:
|
|
||||||
options['InputSlot'] = str(tray.system_name)
|
|
||||||
return options
|
|
||||||
|
|||||||
@@ -97,3 +97,34 @@ class Printer(orm.Model):
|
|||||||
if not printer.tray_ids:
|
if not printer.tray_ids:
|
||||||
self._update_tray_option(db_name, uid, printer, context=context)
|
self._update_tray_option(db_name, uid, printer, context=context)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def print_options(self, cr, uid, report_id, format, context=None):
|
||||||
|
"""
|
||||||
|
Hook to define Tray
|
||||||
|
"""
|
||||||
|
printing_act_obj = self.pool.get('printing.report.xml.action')
|
||||||
|
options = super(ReportXML, self).set_print_options(cr, uid, report_id, format, context=context)
|
||||||
|
|
||||||
|
# Retrieve user default values
|
||||||
|
user = self.pool.get('res.users').browse(cr, uid, context)
|
||||||
|
tray = user.printer_tray_id
|
||||||
|
report = self.browse(cr, uid, report_id, context=context)
|
||||||
|
|
||||||
|
# Retrieve report default values
|
||||||
|
if report.printer_tray_id:
|
||||||
|
tray = report.printer_tray_id
|
||||||
|
|
||||||
|
# Retrieve report-user specific values
|
||||||
|
act_ids = printing_act_obj.search(
|
||||||
|
cr, uid,
|
||||||
|
[('report_id', '=', report.id),
|
||||||
|
('user_id', '=', uid),
|
||||||
|
('action', '!=', 'user_default')], context=context)
|
||||||
|
if act_ids:
|
||||||
|
user_action = printing_act_obj.browse(cr, uid, act_ids[0], context=context)
|
||||||
|
if user_action.tray_id:
|
||||||
|
tray = user_action.tray_id
|
||||||
|
|
||||||
|
if tray:
|
||||||
|
options['InputSlot'] = str(tray.system_name)
|
||||||
|
return options
|
||||||
|
|||||||
Reference in New Issue
Block a user