[MERGE] res.partner.category: add short name_get variant (context toggle), courtesy of Numerigraphe

bzr revid: odo@openerp.com-20111221145443-js9nydzwa2vx4un4
This commit is contained in:
Olivier Dony 2011-12-21 15:54:43 +01:00
commit 1638303686
1 changed files with 13 additions and 2 deletions

View File

@ -36,9 +36,20 @@ class res_payterm(osv.osv):
res_payterm()
class res_partner_category(osv.osv):
def name_get(self, cr, uid, ids, context=None):
if not len(ids):
return []
"""Return the categories' display name, including their direct
parent by default.
:param dict context: the ``partner_category_display`` key can be
used to select the short version of the
category name (without the direct parent),
when set to ``'short'``. The default is
the long version."""
if context is None:
context = {}
if context.get('partner_category_display') == 'short':
return super(res_partner_category, self).name_get(cr, uid, ids, context=context)
reads = self.read(cr, uid, ids, ['name','parent_id'], context=context)
res = []
for record in reads: