[MERGE] res.partner.category: add short name_get variant (context toggle), courtesy...
authorOlivier Dony <odo@openerp.com>
Wed, 21 Dec 2011 14:54:43 +0000 (15:54 +0100)
committerOlivier Dony <odo@openerp.com>
Wed, 21 Dec 2011 14:54:43 +0000 (15:54 +0100)
bzr revid: odo@openerp.com-20111221145443-js9nydzwa2vx4un4

1  2 
openerp/addons/base/res/res_partner.py

@@@ -36,9 -36,15 +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' names with all their parent's names
 -        
 -        The normal name_get behavior can be force by setting 
 -        short_category_name=True in the context.""" 
 -        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: