Skip to content
Snippets Groups Projects
Commit 5cc7c400 authored by Olivier Dony's avatar Olivier Dony
Browse files

[IMP] res.currency: name_search() implementation to match name_get()

bzr revid: odo@openerp.com-20111005002416-vz0vzfpb2uosxu4c
parent 982b2a08
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import re
import time
import netsvc
from osv import fields, osv
......@@ -26,6 +27,8 @@ import tools
from tools.misc import currency
from tools.translate import _
CURRENCY_DISPLAY_PATTERN = re.compile(r'(\w+)\s*(?:\((.*)\))?')
class res_currency(osv.osv):
def _current_rate(self, cr, uid, ids, name, arg, context=None):
if context is None:
......@@ -101,6 +104,18 @@ class res_currency(osv.osv):
r['date'] = currency_date
return res
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100):
if not args:
args = []
if name:
ids = self.search(cr, user, ([('name','=',name)] + args), limit=limit, context=context)
name_match = CURRENCY_DISPLAY_PATTERN.match(name)
if not ids and name_match:
ids = self.search(cr, user, [('name','=', name_match.group(1))] + args, limit=limit, context=context)
else:
ids = self.search(cr, user, args, limit=limit, context=context)
return self.name_get(cr, user, ids, context=context)
def name_get(self, cr, uid, ids, context=None):
if not ids:
return []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment