Started to migrate printing.printer to the new API

This commit is contained in:
Guewen Baconnier
2014-11-17 14:37:44 +01:00
committed by Graeme Gellatly
parent 4a4a015be5
commit 4453dab532

View File

@@ -22,16 +22,15 @@ import cups
from cups import PPD from cups import PPD
from openerp import pooler from openerp import pooler
from openerp.osv import orm, fields from openerp import models, fields, api
class Printer(orm.Model): class Printer(models.Model):
_inherit = 'printing.printer' _inherit = 'printing.printer'
_columns = { tray_ids = fields.One2many(comodel_name='printing.tray',
'tray_ids': fields.one2many('printing.tray', 'printer_id', 'Paper Sources'), inverse_name='printer_id',
} string='Paper Sources')
def _update_tray_option(self, db_name, uid, printer, context=None): def _update_tray_option(self, db_name, uid, printer, context=None):
""" """
@@ -98,32 +97,27 @@ class Printer(orm.Model):
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): @api.multi
""" def print_options(self, report, format):
Hook to define Tray """ Hook to define Tray """
""" printing_act_obj = self.env['printing.report.xml.action']
printing_act_obj = self.pool.get('printing.report.xml.action') options = super(Printer, self).print_options(report, format)
options = super(ReportXML, self).set_print_options(cr, uid, report_id, format, context=context)
# Retrieve user default values # Retrieve user default values
user = self.pool.get('res.users').browse(cr, uid, context) user = self.env.user
tray = user.printer_tray_id tray = user.printer_tray_id
report = self.browse(cr, uid, report_id, context=context)
# Retrieve report default values # Retrieve report default values
if report.printer_tray_id: if report.printer_tray_id:
tray = report.printer_tray_id tray = report.printer_tray_id
# Retrieve report-user specific values # Retrieve report-user specific values
act_ids = printing_act_obj.search( action = printing_act_obj.search([('report_id', '=', report.id),
cr, uid, ('user_id', '=', self.env.uid),
[('report_id', '=', report.id), ('action', '!=', 'user_default')],
('user_id', '=', uid), limit=1)
('action', '!=', 'user_default')], context=context) if action and action.tray_id:
if act_ids: tray = action.tray_id
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: if tray:
options['InputSlot'] = str(tray.system_name) options['InputSlot'] = str(tray.system_name)