diff --git a/category.py b/category.py
index 9960e761a3..4abeb8efa7 100644
--- a/category.py
+++ b/category.py
@@ -1,4 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms.
+#This file is part of Tryton. The COPYRIGHT file at the top level of
+#this repository contains the full copyright notices and license terms.
from trytond.osv import fields, OSV
@@ -8,8 +9,6 @@ class Category(OSV):
_description = __doc__
name = fields.Char('Name', required=True, translate=True)
- complete_name = fields.Function('get_complete_name', type="char",
- string='Complete Name')
parent = fields.Many2One('product.category','Parent', select=1)
childs = fields.One2Many('product.category', 'parent',
string='Childs')
@@ -18,23 +17,17 @@ class Category(OSV):
super(Category, self).__init__()
self._order.insert(0, ('name', 'ASC'))
- def get_complete_name(self, cursor, user, ids, name, arg, context=None):
- res = self.name_get(cursor, user, ids, context=context)
- return dict(res)
-
- def name_get(self, cursor, user, ids, context=None):
+ def get_rec_name(self, cursor, user, ids, name, arg, context=None):
if not ids:
- return []
- if isinstance(ids, (int, long)):
- ids = [ids]
+ return {}
+ res = {}
categories = self.browse(cursor, user, ids, context=context)
- res = []
for category in categories:
if category.parent:
name = category.parent.name+' / '+ category.name
else:
name = category.name
- res.append((category.id, name))
+ res[category.id] = name
return res
Category()
diff --git a/category.xml b/category.xml
index 52ba8a1df5..4f07895046 100644
--- a/category.xml
+++ b/category.xml
@@ -11,7 +11,7 @@ this repository contains the full copyright notices and license terms. -->
-
+
]]>
@@ -39,8 +39,8 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
diff --git a/product.py b/product.py
index 91d6455a38..32be8d15b5 100644
--- a/product.py
+++ b/product.py
@@ -79,35 +79,30 @@ class Product(OSV):
required=True, ondelete='CASCADE')
code = fields.Char("Code", size=None)
description = fields.Text("Description", translate=True)
- complete_name = fields.Function('get_complete_name', string="Complete Name", type="char")
-
- def get_complete_name(self, cursor, user, ids, name, arg, context=None):
- return dict(self.name_get(cursor, user, ids, context=context))
-
- def name_get(self, cursor, user, ids, context=None):
+ def get_rec_name(self, cursor, user, ids, name, arg, context=None):
if not ids:
- return []
- if isinstance(ids, (int, long)):
- ids = [ids]
- res = []
+ return {}
+ res = {}
for product in self.browse(cursor, user, ids, context=context):
name = product.name
if product.code:
name = '[' + product.code + '] ' + product.name
- res.append((product.id, name))
+ res[product.id] = name
return res
- def name_search(self, cursor, user, name, args=None, operator='ilike',
- context=None, limit=None):
- if not args:
- args = []
- ids = self.search(cursor, user, [('code', '=', name)] + args,
- limit=limit, context=context)
- if ids:
- return self.name_get(cursor, user, ids, context=context)
- return super(Product, self).name_search(cursor, user, name,
- args=args, operator=operator, context=context, limit=limit)
+ def search_rec_name(self, cursor, user, name, args, context=None):
+ args2 = []
+ i = 0
+ while i < len(args):
+ ids = self.search(cursor, user, [('code', args[i][1], args[i][2])],
+ context=context)
+ if ids:
+ args2.append(('id', 'in', ids))
+ else:
+ args2.append(('name', args[i][1], args[i][2]))
+ i += 1
+ return args2
def delete(self, cursor, user, ids, context=None):
template_obj = self.pool.get('product.template')
diff --git a/uom.py b/uom.py
index a1153eb6d3..536c2ca0d2 100644
--- a/uom.py
+++ b/uom.py
@@ -82,15 +82,13 @@ class Uom(OSV):
return False
uom = self.browse(cursor, user, context['category'][0],
context=context)
- return category_obj.name_get(cursor, user, uom.category.id,
- context=context)[0]
+ return uom.category.id
else:
if not context['category'][0]:
return False
product = product_obj.browse(cursor, user,
context['category'][0], context=context)
- return category_obj.name_get(cursor, user,
- product.default_uom.category.id, context=context)[0]
+ return product.default_uom.category.id
return False
def on_change_factor(self, cursor, user, ids, value, context=None):