mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[PEP8] - printer_tray
This commit is contained in:
@@ -36,7 +36,8 @@ class ReportXML(orm.Model):
|
|||||||
Hook to define Tray
|
Hook to define Tray
|
||||||
"""
|
"""
|
||||||
printing_act_obj = self.pool.get('printing.report.xml.action')
|
printing_act_obj = self.pool.get('printing.report.xml.action')
|
||||||
options = super(ReportXML, self).set_print_options(cr, uid, report_id, format, context=context)
|
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.pool.get('res.users').browse(cr, uid, context)
|
||||||
@@ -54,7 +55,8 @@ class ReportXML(orm.Model):
|
|||||||
('user_id', '=', uid),
|
('user_id', '=', uid),
|
||||||
('action', '!=', 'user_default')], context=context)
|
('action', '!=', 'user_default')], context=context)
|
||||||
if act_ids:
|
if act_ids:
|
||||||
user_action = printing_act_obj.browse(cr, uid, act_ids[0], context=context)
|
user_action = printing_act_obj.browse(
|
||||||
|
cr, uid, act_ids[0], context=context)
|
||||||
if user_action.tray_id:
|
if user_action.tray_id:
|
||||||
tray = user_action.tray_id
|
tray = user_action.tray_id
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ class Printer(orm.Model):
|
|||||||
_inherit = 'printing.printer'
|
_inherit = 'printing.printer'
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'tray_ids': fields.one2many('printing.tray', 'printer_id', 'Paper Sources'),
|
'tray_ids': fields.one2many('printing.tray', 'printer_id',
|
||||||
|
'Paper Sources'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _update_tray_option(self, db_name, uid, printer, context=None):
|
def _update_tray_option(self, db_name, uid, printer, context=None):
|
||||||
@@ -54,7 +55,8 @@ class Printer(orm.Model):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
for tray_opt in option.choices:
|
for tray_opt in option.choices:
|
||||||
if tray_opt['choice'] not in [t.system_name for t in printer.tray_ids]:
|
if tray_opt['choice'] not in [
|
||||||
|
t.system_name for t in printer.tray_ids]:
|
||||||
tray_vals = {
|
tray_vals = {
|
||||||
'name': tray_opt['text'],
|
'name': tray_opt['text'],
|
||||||
'system_name': tray_opt['choice'],
|
'system_name': tray_opt['choice'],
|
||||||
@@ -76,7 +78,8 @@ class Printer(orm.Model):
|
|||||||
"""
|
"""
|
||||||
db, pool = pooler.get_db_and_pool(db_name)
|
db, pool = pooler.get_db_and_pool(db_name)
|
||||||
cr = db.cursor()
|
cr = db.cursor()
|
||||||
res = super(Printer, self).update_printers_status(db_name, uid, context=context)
|
res = super(Printer, self).update_printers_status(db_name, uid,
|
||||||
|
context=context)
|
||||||
try:
|
try:
|
||||||
connection = cups.Connection()
|
connection = cups.Connection()
|
||||||
printers = connection.getPrinters()
|
printers = connection.getPrinters()
|
||||||
@@ -84,7 +87,9 @@ class Printer(orm.Model):
|
|||||||
except:
|
except:
|
||||||
server_error = True
|
server_error = True
|
||||||
|
|
||||||
printer_ids = self.search(cr, uid, [('system_name', 'in', printers.keys())], context=context)
|
printer_ids = self.search(cr, uid,
|
||||||
|
[('system_name', 'in', printers.keys())],
|
||||||
|
context=context)
|
||||||
if server_error:
|
if server_error:
|
||||||
vals = {'status': 'server_error'}
|
vals = {'status': 'server_error'}
|
||||||
self.write(cr, uid, printer_ids, vals, context=context)
|
self.write(cr, uid, printer_ids, vals, context=context)
|
||||||
@@ -95,5 +100,6 @@ class Printer(orm.Model):
|
|||||||
for printer in printer_list:
|
for printer in printer_list:
|
||||||
# XXX we consider config of printer won't change
|
# XXX we consider config of printer won't change
|
||||||
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
|
||||||
|
|||||||
@@ -29,5 +29,6 @@ class PrinterTray(orm.Model):
|
|||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Name', size=64, required=True),
|
'name': fields.char('Name', size=64, required=True),
|
||||||
'system_name': fields.char('System Name', size=64, required=True),
|
'system_name': fields.char('System Name', size=64, required=True),
|
||||||
'printer_id': fields.many2one('printing.printer', 'Printer', required=True),
|
'printer_id': fields.many2one('printing.printer', 'Printer',
|
||||||
|
required=True),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class ReportXMLAction(orm.Model):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def behaviour(self, cr, uid, act_id, context=None):
|
def behaviour(self, cr, uid, act_id, context=None):
|
||||||
res = super(ReportXMLAction, self).behaviour(cr, uid, act_id, context=context)
|
res = super(ReportXMLAction, self).behaviour(cr, uid, act_id,
|
||||||
|
context=context)
|
||||||
action = self.browse(cr, uid, act_id, context=context)
|
action = self.browse(cr, uid, act_id, context=context)
|
||||||
res['tray'] = action.printer_tray_id.system_name
|
res['tray'] = action.printer_tray_id.system_name
|
||||||
return res
|
return res
|
||||||
|
|||||||
Reference in New Issue
Block a user