Sandy Carter (http://www.savoirfairelinux.com) has proposed merging lp:~savoirfairelinux-openerp/openerp-hr/department_sequence_concatination_NoneType into lp:openerp-hr.
Requested reviews: HR Core Editors (hr-core-editors) For more details, see: https://code.launchpad.net/~savoirfairelinux-openerp/openerp-hr/department_sequence_concatination_NoneType/+merge/212436 Fix a name_search bug and add a test to prevent future regressions: openerp.addons.hr_department_sequence.hr_department in name_search TypeError: can only concatenate list (not "NoneType") to list -- https://code.launchpad.net/~savoirfairelinux-openerp/openerp-hr/department_sequence_concatination_NoneType/+merge/212436 Your team HR Core Editors is requested to review the proposed merge of lp:~savoirfairelinux-openerp/openerp-hr/department_sequence_concatination_NoneType into lp:openerp-hr.
=== modified file 'hr_department_sequence/hr_department.py' --- hr_department_sequence/hr_department.py 2013-12-04 13:35:42 +0000 +++ hr_department_sequence/hr_department.py 2014-03-24 14:52:50 +0000 @@ -52,6 +52,8 @@ for record in self.browse(cr, uid, ids, context=context or {})] def name_search(self, cr, uid, name='', args=None, operator='ilike', context=None, limit=100): + if args is None: + args = [] ids = self.search(cr, uid, ['|', ('code', 'ilike', name), ('name', 'ilike', name)] + args, limit=limit, context=context) return self.name_get(cr, uid, ids, context=context) === added directory 'hr_department_sequence/tests' === added file 'hr_department_sequence/tests/__init__.py' --- hr_department_sequence/tests/__init__.py 1970-01-01 00:00:00 +0000 +++ hr_department_sequence/tests/__init__.py 2014-03-24 14:52:50 +0000 @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2010 - 2014 Savoir-faire Linux +# (<http://www.savoirfairelinux.com>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from . import ( + test_hr_department, +) + +checks = [ + test_hr_department, +] === added file 'hr_department_sequence/tests/test_hr_department.py' --- hr_department_sequence/tests/test_hr_department.py 1970-01-01 00:00:00 +0000 +++ hr_department_sequence/tests/test_hr_department.py 2014-03-24 14:52:50 +0000 @@ -0,0 +1,62 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2010 - 2014 Savoir-faire Linux +# (<http://www.savoirfairelinux.com>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from openerp.tests.common import TransactionCase + + +class test_department(TransactionCase): + + def setUp(self): + super(test_department, self).setUp() + # Clean up registries + self.registry('ir.model').clear_caches() + self.registry('ir.model.data').clear_caches() + # Get registries + self.user_model = self.registry("res.users") + self.department_model = self.registry("hr.department") + # Get context + self.context = self.user_model.context_get(self.cr, self.uid) + self.vals = { + 'name': 'test', + 'code': 'TEST', + 'sequence': 1, + } + + def test_create_department(self): + cr, uid, context = self.cr, self.uid, self.context + department_id = self.department_model.create( + self.cr, self.uid, self.vals, context=self.context) + department = self.department_model.browse(cr, uid, department_id, + context=context) + self.assertEqual(self.vals['name'], department.name) + self.assertEqual(self.vals['code'], department.code) + self.assertEqual(self.vals['sequence'], department.sequence) + + def test_name_search_department(self): + cr, uid, context = self.cr, self.uid, self.context + department_id = self.department_model.create( + self.cr, self.uid, self.vals, context=self.context) + + found_id = self.department_model.name_search( + cr, uid, name=self.vals['name'], context=context)[0][0] + self.assertEqual(department_id, found_id, + "Found wrong id for name=%s" % self.vals['name'])
-- Mailing list: https://launchpad.net/~openerp-community-reviewer Post to : openerp-community-reviewer@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-community-reviewer More help : https://help.launchpad.net/ListHelp