[IMP] base_report_to_printer - simplify calls on class

This commit is contained in:
Yannick Vaucher
2013-09-30 13:46:04 +02:00
parent 18a351349d
commit ac03496959

View File

@@ -69,7 +69,7 @@ class printing_printer(orm.Model):
self.last_update = None self.last_update = None
self.updating = False self.updating = False
def update_printers_status(self, db_name, uid, context): def update_printers_status(self, db_name, uid, context=None):
db, pool = pooler.get_db_and_pool(db_name) db, pool = pooler.get_db_and_pool(db_name)
cr = db.cursor() cr = db.cursor()
@@ -86,12 +86,14 @@ class printing_printer(orm.Model):
5 : 'error' 5 : 'error'
} }
if context is None:
context = {}
try: try:
# Skip update to avoid the thread being created again # Skip update to avoid the thread being created again
ctx = context.copy() ctx = context.copy()
ctx['skip_update'] = True ctx['skip_update'] = True
ids = self.pool.get('printing.printer').search(cr, uid, [], context=ctx) ids = self.search(cr, uid, [], context=ctx)
for printer in self.pool.get('printing.printer').browse(cr, uid, ids, context=ctx): for printer in self.browse(cr, uid, ids, context=ctx):
vals = {} vals = {}
if server_error: if server_error:
status = 'server-error' status = 'server-error'
@@ -107,7 +109,7 @@ class printing_printer(orm.Model):
status = 'unavailable' status = 'unavailable'
vals['status'] = status vals['status'] = status
self.pool.get('printing.printer').write(cr, uid, [printer.id], vals, context) self.write(cr, uid, [printer.id], vals, context)
cr.commit() cr.commit()
except: except:
cr.rollback() cr.rollback()
@@ -264,13 +266,13 @@ class report_xml(orm.Model):
if context is None: if context is None:
context={} context={}
result = {} result = {}
printer_obj = self.pool.get('printing.printer')
# Set hardcoded default action # Set hardcoded default action
default_action = 'client' default_action = 'client'
# Retrieve system wide printer # Retrieve system wide printer
default_printer = self.pool.get('printing.printer').get_default(cr,uid,context) default_printer = printer_obj.get_default(cr, uid, context=context)
if default_printer: if default_printer:
default_printer = self.pool.get('printing.printer').browse(cr,uid,default_printer,context).system_name default_printer = printer_obj.browse(cr, uid, default_printer, context=context).system_name
# Retrieve user default values # Retrieve user default values