[PEP8] - printer_tray

This commit is contained in:
Laetitia Gangloff
2015-09-28 12:37:17 +02:00
parent 5e46167775
commit f5f2028d34
6 changed files with 26 additions and 16 deletions

View File

@@ -36,7 +36,8 @@ class ReportXML(orm.Model):
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)
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)
@@ -54,7 +55,8 @@ class ReportXML(orm.Model):
('user_id', '=', uid),
('action', '!=', 'user_default')], context=context)
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:
tray = user_action.tray_id

View File

@@ -30,7 +30,8 @@ class Printer(orm.Model):
_inherit = 'printing.printer'
_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):
@@ -54,7 +55,8 @@ class Printer(orm.Model):
return
try:
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 = {
'name': tray_opt['text'],
'system_name': tray_opt['choice'],
@@ -76,7 +78,8 @@ class Printer(orm.Model):
"""
db, pool = pooler.get_db_and_pool(db_name)
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:
connection = cups.Connection()
printers = connection.getPrinters()
@@ -84,7 +87,9 @@ class Printer(orm.Model):
except:
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:
vals = {'status': 'server_error'}
self.write(cr, uid, printer_ids, vals, context=context)
@@ -95,5 +100,6 @@ class Printer(orm.Model):
for printer in printer_list:
# XXX we consider config of printer won't change
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

View File

@@ -29,5 +29,6 @@ class PrinterTray(orm.Model):
_columns = {
'name': fields.char('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),
}

View File

@@ -32,7 +32,8 @@ class ReportXMLAction(orm.Model):
}
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)
res['tray'] = action.printer_tray_id.system_name
return res