From 0b593ada11f6222803949705c508a5616c3e6a3e Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Tue, 24 Jun 2014 17:42:48 +0530 Subject: [PATCH 1/3] Server Translation: Fixed the issue search on translated field do not return true result, search on tranlsated field fails due to expression parsing which fetches ids from ir_translation as well as working table and UNION of this makes search fruitless, also search fails for in language other then english when you enter part of a string for the field to search. --- openerp/osv/expression.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index 68ad4c2e589..18c82306bc5 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -1037,34 +1037,30 @@ class expression(object): unaccent = self._unaccent if sql_operator.endswith('like') else lambda x: x - trans_left = unaccent('value') - quote_left = unaccent(_quote(left)) instr = unaccent('%s') if sql_operator == 'in': # params will be flatten by to_sql() => expand the placeholders instr = '(%s)' % ', '.join(['%s'] * len(right)) - subselect = """(SELECT res_id - FROM ir_translation - WHERE name = %s - AND lang = %s - AND type = %s - AND {trans_left} {operator} {right} - ) UNION ( - SELECT id - FROM "{table}" - WHERE {left} {operator} {right} - ) - """.format(trans_left=trans_left, operator=sql_operator, - right=instr, table=working_model._table, left=quote_left) + subselect = """WITH temp_irt_current (id, name) as ( + SELECT ct.id, coalesce(it.value,ct.{quote_left}) + FROM {current_table} ct + LEFT JOIN ir_translation it ON (it.name = %s and + it.lang = %s and + it.type = %s and + it.res_id = ct.id and + it.value != '') + ) + 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'), + operator=sql_operator, right=instr) params = ( working_model._name + ',' + left, context.get('lang') or 'en_US', 'model', right, - right, ) push(create_substitution_leaf(leaf, ('id', inselect_operator, (subselect, params)), working_model)) From ac5a0b046b41fa0041db3f789ef725d5ed705027 Mon Sep 17 00:00:00 2001 From: Yogesh Parekh Date: Tue, 24 Jun 2014 11:26:49 +0530 Subject: [PATCH 2/3] [IMP]: Improve copy method to set stage_id in draft stage --- addons/crm_claim/crm_claim.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index 04e12c8bce8..ee4aff1e7e3 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -179,6 +179,13 @@ class crm_claim(base_stage, osv.osv): address = self.pool.get('res.partner').browse(cr, uid, part) return {'value': {'email_from': address.email, 'partner_phone': address.phone}} + 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 # ------------------------------------------------------- From 4bfcbb2a480db6b72b6db84420a39dcf641bbbb1 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Wed, 25 Jun 2014 10:57:10 +0200 Subject: [PATCH 3/3] [FIX] fields property: do not create empty properties fixes #595 In the case where a property for the company exists but has no related record (e.g. in case of type m2o with no defined value), not setting a value to this field for a new record would create a new property (as browse_null is not an instance of browse_record) --- openerp/osv/fields.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 49421365852..040548ec7cc 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -1428,7 +1428,8 @@ class property(function): default_val = self._get_default(obj, cr, uid, prop_name, context) 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: property_create = True elif default_val != id_val: