[MERGE] forward port of branch 7.0 up to 4bfcbb2

This commit is contained in:
Christophe Simonis 2014-06-25 11:35:11 +02:00
commit a1b3e22a17
3 changed files with 21 additions and 17 deletions

View File

@ -164,6 +164,13 @@ class crm_claim(osv.osv):
# context: no_log, because subtype already handle this # context: no_log, because subtype already handle this
return super(crm_claim, self).create(cr, uid, vals, context=context) return super(crm_claim, self).create(cr, uid, vals, context=context)
def copy(self, cr, uid, id, default=None, context=None):
claim = self.browse(cr, uid, id, context=context)
default = dict(default or {},
stage_id = self._get_default_stage_id(cr, uid, context=context),
name = _('%s (copy)') % claim.name)
return super(crm_claim, self).copy(cr, uid, id, default, context=context)
# ------------------------------------------------------- # -------------------------------------------------------
# Mail gateway # Mail gateway
# ------------------------------------------------------- # -------------------------------------------------------

View File

@ -1036,34 +1036,30 @@ class expression(object):
unaccent = self._unaccent if sql_operator.endswith('like') else lambda x: x unaccent = self._unaccent if sql_operator.endswith('like') else lambda x: x
trans_left = unaccent('value')
quote_left = unaccent(_quote(left))
instr = unaccent('%s') instr = unaccent('%s')
if sql_operator == 'in': if sql_operator == 'in':
# params will be flatten by to_sql() => expand the placeholders # params will be flatten by to_sql() => expand the placeholders
instr = '(%s)' % ', '.join(['%s'] * len(right)) instr = '(%s)' % ', '.join(['%s'] * len(right))
subselect = """(SELECT res_id subselect = """WITH temp_irt_current (id, name) as (
FROM ir_translation SELECT ct.id, coalesce(it.value,ct.{quote_left})
WHERE name = %s FROM {current_table} ct
AND lang = %s LEFT JOIN ir_translation it ON (it.name = %s and
AND type = %s it.lang = %s and
AND {trans_left} {operator} {right} it.type = %s and
) UNION ( it.res_id = ct.id and
SELECT id it.value != '')
FROM "{table}" )
WHERE {left} {operator} {right} SELECT id FROM temp_irt_current WHERE {name} {operator} {right} order by name
) """.format(current_table=working_model._table, quote_left=_quote(left), name=unaccent('name'),
""".format(trans_left=trans_left, operator=sql_operator, operator=sql_operator, right=instr)
right=instr, table=working_model._table, left=quote_left)
params = ( params = (
working_model._name + ',' + left, working_model._name + ',' + left,
context.get('lang') or 'en_US', context.get('lang') or 'en_US',
'model', 'model',
right, right,
right,
) )
push(create_substitution_leaf(leaf, ('id', inselect_operator, (subselect, params)), working_model)) push(create_substitution_leaf(leaf, ('id', inselect_operator, (subselect, params)), working_model))

View File

@ -1505,7 +1505,8 @@ class property(function):
default_val = self._get_default(obj, cr, uid, prop_name, context) default_val = self._get_default(obj, cr, uid, prop_name, context)
property_create = False property_create = False
if isinstance(default_val, openerp.osv.orm.browse_record): if isinstance(default_val, (openerp.osv.orm.browse_record,
openerp.osv.orm.browse_null)):
if default_val.id != id_val: if default_val.id != id_val:
property_create = True property_create = True
elif default_val != id_val: elif default_val != id_val: