mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
Move the 'skip_update' right in the browse, it prevents a loop
See https://github.com/odoo/odoo/issues/3644 Also, it helps to have the value set/read in context close to each other.
This commit is contained in:
committed by
Sylvain GARANCHER
parent
39bd5e94e4
commit
7ac2564668
@@ -148,7 +148,6 @@ class PrintingPrinterPolling(models.Model):
|
|||||||
try:
|
try:
|
||||||
self.env = api.Environment(cr, uid, context)
|
self.env = api.Environment(cr, uid, context)
|
||||||
printer_obj = self.env['printing.printer']
|
printer_obj = self.env['printing.printer']
|
||||||
printer_obj = printer_obj.with_context(skip_update=True)
|
|
||||||
with self.start_update() as locked:
|
with self.start_update() as locked:
|
||||||
if not locked:
|
if not locked:
|
||||||
return # could not obtain lock
|
return # could not obtain lock
|
||||||
@@ -264,27 +263,25 @@ class PrintingPrinter(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update printer status if current status is more than 10s old."""
|
"""Update printer status if current status is more than 10s old."""
|
||||||
# We won't acquire locks - we're only assigning from immutable data
|
|
||||||
if not self.env.context or 'skip_update' in self.env.context:
|
|
||||||
return True
|
|
||||||
polling_obj = self.env['printing.printer.polling']
|
polling_obj = self.env['printing.printer.polling']
|
||||||
|
|
||||||
if polling_obj.need_update():
|
if polling_obj.need_update():
|
||||||
self.start_printer_update()
|
self.start_printer_update()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.v7
|
@api.v7
|
||||||
def browse(self, cr, uid, arg=None, context=None):
|
def browse(self, cr, uid, arg=None, context=None):
|
||||||
# https://github.com/odoo/odoo/issues/3644
|
|
||||||
# self.update(cr, uid, context=context)
|
|
||||||
_super = super(PrintingPrinter, self)
|
_super = super(PrintingPrinter, self)
|
||||||
return _super.browse(cr, uid, arg=arg, context=context)
|
recs = _super.browse(cr, uid, arg=arg, context=context)
|
||||||
|
if not recs._context.get('skip_update'):
|
||||||
|
recs.with_context(skip_update=True).update()
|
||||||
|
return recs
|
||||||
|
|
||||||
@api.v8
|
@api.v8
|
||||||
def browse(self, arg=None):
|
def browse(self, arg=None):
|
||||||
self.update()
|
recs = super(PrintingPrinter, self).browse(arg=arg)
|
||||||
return super(PrintingPrinter, self).browse(arg=arg)
|
if not recs._context.get('skip_update'):
|
||||||
|
recs.with_context(skip_update=True).update()
|
||||||
|
return recs
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def set_default(self):
|
def set_default(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user