summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ledoux <dle@odoo.com>2015-01-30 15:00:21 +0100
committerDenis Ledoux <dle@odoo.com>2015-01-30 15:04:20 +0100
commit05c907b60be23b5cfc463147a87fe2425cfecbdd (patch)
tree63d79c1abf8ce168774bdbdc708e8f360b93058b
parenta804d9a70f4288cde4d08d6dc0970a2b0c495b6a (diff)
[FIX] res: currency, rates name_search
In currencies, advanced search with "equals" or "not equals" on rates was not possible for something else than a date, in server format (crash). This is because the name field of the model res.currency.rate is a date This is now possible to search rates with just a float and the equal operators, it returns currencies which are having at least one rate set to this float value This is also possible to search rates with the equal operators with a date in user (context) date format.
-rw-r--r--openerp/addons/base/res/res_currency.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py
index dac5988b585..5a92eba01df 100644
--- a/openerp/addons/base/res/res_currency.py
+++ b/openerp/addons/base/res/res_currency.py
@@ -259,6 +259,25 @@ class res_currency_rate(osv.osv):
}
_order = "name desc"
+ def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
+ if operator in ['=', '!=']:
+ try:
+ date_format = '%Y-%m-%d'
+ if context.get('lang'):
+ lang_obj = self.pool['res.lang']
+ lang_ids = lang_obj.search(cr, user, [('code', '=', context['lang'])], context=context)
+ if lang_ids:
+ date_format = lang_obj.browse(cr, user, lang_ids[0], context=context).date_format
+ name = time.strftime('%Y-%m-%d', time.strptime(name, date_format))
+ except ValueError:
+ try:
+ args.append(('rate', operator, float(name)))
+ except ValueError:
+ return []
+ name = ''
+ operator = 'ilike'
+ return super(res_currency_rate, self).name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
+
res_currency_rate()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: