[MERGE] forward port of branch saas-2 up to revid 5007 chs@openerp.com-20140206110220-myn57cryam1y4k9v

bzr revid: chs@openerp.com-20140206110423-qe4h5ip2dg6dm7ph
This commit is contained in:
Christophe Simonis 2014-02-06 12:04:23 +01:00
commit 500fea28b7
4 changed files with 21 additions and 4 deletions

View File

@ -13,6 +13,7 @@ from openerp.osv import orm
from openerp.tools.translate import _
from openerp.tools.misc import DEFAULT_SERVER_DATE_FORMAT,\
DEFAULT_SERVER_DATETIME_FORMAT
from openerp.tools import html_sanitize
REFERENCING_FIELDS = set([None, 'id', '.id'])
def only_ref_fields(record):
@ -188,7 +189,7 @@ class ir_fields_converter(orm.Model):
def _str_id(self, cr, uid, model, column, value, context=None):
return value, []
_str_to_reference = _str_to_char = _str_to_text = _str_to_binary = _str_id
_str_to_reference = _str_to_char = _str_to_text = _str_to_binary = _str_to_html = _str_id
def _str_to_date(self, cr, uid, model, column, value, context=None):
try:

View File

@ -8,6 +8,7 @@ class test_base(common.TransactionCase):
def setUp(self):
super(test_base,self).setUp()
self.res_partner = self.registry('res.partner')
self.res_users = self.registry('res.users')
# samples use effective TLDs from the Mozilla public suffix
# list at http://publicsuffix.org
@ -282,6 +283,21 @@ class test_base(common.TransactionCase):
p0.refresh()
self.assertEquals(p0.vat, sunhelmvat2, 'Commercial fields must be automatically synced')
def test_60_read_group(self):
cr, uid = self.cr, self.uid
for user_data in [
{'name': 'Alice', 'login': 'alice', 'color': 1, 'function': 'Friend'},
{'name': 'Bob', 'login': 'bob', 'color': 2, 'function': 'Friend'},
{'name': 'Eve', 'login': 'eve', 'color': 3, 'function': 'Eavesdropper'},
]:
self.res_users.create(cr, uid, user_data)
groups_data = self.res_users.read_group(cr, uid, domain=[('login', 'in', ('alice', 'bob', 'eve'))], fields=['name', 'color', 'function'], groupby='function')
self.assertEqual(len(groups_data), 2, "Incorrect number of results when grouping on a field")
for group_data in groups_data:
self.assertIn('color', group_data, "Aggregated data for the column 'color' is not present in read_group return values")
self.assertEqual(group_data['color'], 3, "Incorrect sum for aggregated data for the column 'color'")
class test_partner_recursion(common.TransactionCase):
def setUp(self):

View File

@ -2293,12 +2293,12 @@ class BaseModel(object):
f for f in fields
if f not in ('id', 'sequence')
if fget[f]['type'] in ('integer', 'float')
if (f in self._columns and getattr(self._columns[f], '_classic_write'))]
if (f in self._all_columns and getattr(self._all_columns[f].column, '_classic_write'))]
for f in aggregated_fields:
group_operator = fget[f].get('group_operator', 'sum')
if flist:
flist += ', '
qualified_field = '"%s"."%s"' % (self._table, f)
qualified_field = self._inherits_join_calc(f, query)
flist += "%s(%s) AS %s" % (group_operator, qualified_field, f)
gb = groupby and (' GROUP BY ' + qualified_groupby_field) or ''

View File

@ -172,7 +172,7 @@ class GettextAlias(object):
cr = getattr(s, 'cr', None)
if not cr and allow_create:
db = self._get_db()
if db:
if db is not None:
cr = db.cursor()
is_new_cr = True
return cr, is_new_cr