From d0d0b8747e46a8e87431dfbb1b30172145ff90fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 17 Feb 2009 11:46:14 +0100 Subject: [PATCH] Replace name_get, name_search with get_rec_name and search_rec_name Return only id for default value of many2one --- category.py | 19 ++++++------------- category.xml | 6 +++--- product.py | 37 ++++++++++++++++--------------------- uom.py | 6 ++---- 4 files changed, 27 insertions(+), 41 deletions(-) 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. -->