Revert "[FIX] fields: `digits()` computation"
This reverts commit eeedd2d9f5
.
This revision introduces an issue more serious than the ones
it fixes. This is no longer possible to receive an email
aimed a sale.order thread with catchall.
To reproduce the issue:
- Create a new sale order
- Send a message in the thread to the customer
- Reply to the mail received in the customer mailbox
- Traceback, AttributeError: digits
opw-640370
This commit is contained in:
parent
7d69759e73
commit
49cb46fb78
|
@ -1054,8 +1054,7 @@ class Float(Field):
|
|||
@property
|
||||
def digits(self):
|
||||
if callable(self._digits):
|
||||
with fields._get_cursor() as cr:
|
||||
return self._digits(cr)
|
||||
return self._digits(fields.get_cursor())
|
||||
else:
|
||||
return self._digits
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ import pytz
|
|||
import re
|
||||
import xmlrpclib
|
||||
from operator import itemgetter
|
||||
from contextlib import contextmanager
|
||||
from psycopg2 import Binary
|
||||
|
||||
import openerp
|
||||
|
@ -53,22 +52,13 @@ from openerp.tools import float_repr, float_round, frozendict, html_sanitize
|
|||
import simplejson
|
||||
from openerp import SUPERUSER_ID, registry
|
||||
|
||||
@contextmanager
|
||||
def _get_cursor():
|
||||
# yield a valid cursor from any environment or create a new one if none found
|
||||
def get_cursor():
|
||||
# retrieve a valid cursor from any environment
|
||||
from openerp.api import Environment
|
||||
from openerp.http import request
|
||||
try:
|
||||
request.env # force request's env to be computed
|
||||
except RuntimeError:
|
||||
pass # ignore if not in a request
|
||||
for env in Environment.envs:
|
||||
if not env.cr.closed:
|
||||
yield env.cr
|
||||
break
|
||||
else:
|
||||
with registry().cursor() as cr:
|
||||
yield cr
|
||||
return env.cr
|
||||
raise RuntimeError("No valid cursor found")
|
||||
|
||||
EMPTY_DICT = frozendict()
|
||||
|
||||
|
@ -406,8 +396,7 @@ class float(_column):
|
|||
@property
|
||||
def digits(self):
|
||||
if self._digits_compute:
|
||||
with _get_cursor() as cr:
|
||||
return self._digits_compute(cr)
|
||||
return self._digits_compute(get_cursor())
|
||||
else:
|
||||
return self._digits
|
||||
|
||||
|
@ -1327,8 +1316,7 @@ class function(_column):
|
|||
@property
|
||||
def digits(self):
|
||||
if self._digits_compute:
|
||||
with _get_cursor() as cr:
|
||||
return self._digits_compute(cr)
|
||||
return self._digits_compute(get_cursor())
|
||||
else:
|
||||
return self._digits
|
||||
|
||||
|
|
Loading…
Reference in New Issue