mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] base_report_to_printer - simplify calls on class
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user