[MERGE] forward port of branch 8.0 up to 43a4ffe

This commit is contained in:
Christophe Simonis
2016-01-26 18:20:11 +01:00
5 changed files with 35 additions and 7 deletions
+1 -1
View File
@@ -707,7 +707,7 @@ class sale_order(osv.osv):
:return: True
"""
context = context or {}
context = dict(context or {})
context['lang'] = self.pool['res.users'].browse(cr, uid, uid).lang
procurement_obj = self.pool.get('procurement.order')
sale_line_obj = self.pool.get('sale.order.line')
+4
View File
@@ -785,6 +785,10 @@ instance.web.PivotView = instance.web.View.extend({
title: this.title,
};
var c = openerp.webclient.crashmanager;
if(table.measure_row.length + 1 > 256) {
c.show_message(_t("For Excel compatibility, data cannot be exported if there is more than 256 columns.\n\nTip: try to flip axis, filter further or reduce the number of measures."))
return;
}
this.session.get_file({
url: '/web/pivot/export_xls',
data: {data: JSON.stringify(table)},
+12
View File
@@ -164,6 +164,9 @@ class Message(models.Model):
size = fields.Integer(compute='_compute_size', search='_search_size')
double_size = fields.Integer(compute='_compute_double_size')
discussion_name = fields.Char(related='discussion.name')
author_partner = fields.Many2one(
'res.partner', compute='_compute_author_partner',
search='_search_author_partner')
@api.one
@api.constrains('author', 'discussion')
@@ -209,6 +212,15 @@ class Message(models.Model):
size = self.size
self.double_size = self.double_size + size
@api.one
@api.depends('author', 'author.partner_id')
def _compute_author_partner(self):
self.author_partner = author.partner_id
@api.model
def _search_author_partner(self, operator, value):
return [('author.partner_id', operator, value)]
class MixedModel(models.Model):
_name = 'test_new_api.mixed'
@@ -423,6 +423,13 @@ class TestNewFields(common.TransactionCase):
defaults = self.env['test_new_api.mixed'].default_get(['number'])
self.assertEqual(defaults, {'number': 3.14})
def test_50_search_many2one(self):
""" test search through a path of computed fields"""
messages = self.env['test_new_api.message'].search(
[('author_partner.name', '=', 'Demo User')])
self.assertEqual(messages, self.env.ref('test_new_api.message_0_1'))
class TestMagicFields(common.TransactionCase):
+11 -6
View File
@@ -842,12 +842,12 @@ class expression(object):
# as after transforming the column, it will go through this loop once again
# ----------------------------------------
elif len(path) > 1 and column._type == 'many2one' and column._auto_join:
elif len(path) > 1 and column and column._type == 'many2one' and column._auto_join:
# res_partner.state_id = res_partner__state_id.id
leaf.add_join_context(comodel, path[0], 'id', path[0])
push(create_substitution_leaf(leaf, (path[1], operator, right), comodel))
elif len(path) > 1 and column._type == 'one2many' and column._auto_join:
elif len(path) > 1 and column and column._type == 'one2many' and column._auto_join:
# res_partner.id = res_partner__bank_ids.partner_id
leaf.add_join_context(comodel, 'id', column._fields_id, path[0])
domain = column._domain(model) if callable(column._domain) else column._domain
@@ -858,16 +858,16 @@ class expression(object):
push(create_substitution_leaf(leaf, elem, comodel))
push(create_substitution_leaf(leaf, AND_OPERATOR, comodel))
elif len(path) > 1 and column._auto_join:
elif len(path) > 1 and column and column._auto_join:
raise NotImplementedError('_auto_join attribute not supported on many2many column %s' % left)
elif len(path) > 1 and column._type == 'many2one':
elif len(path) > 1 and column and column._type == 'many2one':
right_ids = comodel.search(cr, uid, [(path[1], operator, right)], context=dict(context, active_test=False))
leaf.leaf = (path[0], 'in', right_ids)
push(leaf)
# Making search easier when there is a left operand as column.o2m or column.m2m
elif len(path) > 1 and column._type in ['many2many', 'one2many']:
elif len(path) > 1 and column and column._type in ['many2many', 'one2many']:
right_ids = comodel.search(cr, uid, [(path[1], operator, right)], context=context)
table_ids = model.search(cr, uid, [(path[0], 'in', right_ids)], context=dict(context, active_test=False))
leaf.leaf = ('id', 'in', table_ids)
@@ -884,7 +884,12 @@ class expression(object):
domain = []
else:
# Let the field generate a domain.
recs = model.browse(cr, uid, [], context)
if len(path) > 1:
right = comodel.search(
cr, uid, [(path[1], operator, right)],
context=context)
operator = 'in'
recs = model.browse(cr, uid, [], context=context)
domain = field.determine_domain(recs, operator, right)
if not domain: