diff --git a/__init__.py b/__init__.py index 9e147fed66..5925ec105c 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,31 @@ + +# Copyright (c) 2004-2007 TINY SPRL. (http://tiny.be) +# Copyright (c) 2007 Cedric Krier. +# Copyright (c) 2007 Bertrand Chenal. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contact a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + import corporation_type import partner import state diff --git a/category.py b/category.py index 9c388e3135..a4b642fa13 100644 --- a/category.py +++ b/category.py @@ -9,35 +9,12 @@ class Category(OSV): _order = 'parent,name' _parent_name = 'parent' - def name_get(self, cursor, user, ids, context=None): - - if not len(ids): - return [] - 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)) - return res - - def _name_get_fnc(self, cursor, user, obj_id, name, value, arg, - context=None): - res = self.name_get(cursor, user, ids, context) - return dict(res) - - def check_recursion(self, cursor, user, ids, parent=None): - return super(Category, self).check_recursion(cursor, user, - ids,parent="parent") - _columns = { 'name': fields.Char('Category Name', required=True, size=64, states= STATES,), 'parent': fields.Many2One('partner.category', 'Parent Category', select=True, states= STATES,), - 'complete_name': fields.Function(_name_get_fnc, method=True, + 'complete_name': fields.Function('complete_name', type="char", string='Name', states= STATES,), 'childs': fields.One2Many('partner.category', 'parent', 'Childs Category', states= STATES,), @@ -53,4 +30,23 @@ class Category(OSV): 'Error ! You can not create recursive categories.', ['parent']) ] + def complete_name(self, cursor, user, obj_id, name, value, arg, + context=None): + res = self.name_get(cursor, user, ids, context) + return dict(res) + + def name_get(self, cursor, user, ids, context=None): + + if not len(ids): + return [] + 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)) + return res + Category() diff --git a/partner.py b/partner.py index fd0d7f7577..c89f0b851c 100644 --- a/partner.py +++ b/partner.py @@ -1,6 +1,7 @@ from trytond.osv import fields, OSV STATES = {'readonly': "active == False",} + class Partner(OSV): "Partner"