[IMP] base: allow the category name to not include the parents if the context requires it
authorNumerigraphe - Lionel Sausin <ls@numerigraphe.fr>
Thu, 15 Dec 2011 14:56:04 +0000 (15:56 +0100)
committerNumerigraphe - Lionel Sausin <ls@numerigraphe.fr>
Thu, 15 Dec 2011 14:56:04 +0000 (15:56 +0100)
bzr revid: ls@numerigraphe.fr-20111215145604-wu2muv9m9gb9c9h4

openerp/addons/base/res/res_partner.py
openerp/addons/base/res/res_partner_view.xml

index 32b5e08..fc481fd 100644 (file)
@@ -37,13 +37,20 @@ res_payterm()
 
 class res_partner_category(osv.osv):
     def name_get(self, cr, uid, ids, context=None):
+        """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 []
+        if context is None:
+            context = {}
         reads = self.read(cr, uid, ids, ['name','parent_id'], context=context)
         res = []
         for record in reads:
             name = record['name']
-            if record['parent_id']:
+            if record['parent_id'] and not context.get('short_category_name',
+                                                       False):
                 name = record['parent_id'][1]+' / '+name
             res.append((record['id'], name))
         return res
index b489a4d..c575250 100644 (file)
             <field name="res_model">res.partner</field>
             <field name="view_type">form</field>
             <field name="view_mode">kanban</field>
-            <field name="context">{"search_default_customer":1}</field>
+            <field name="context">{"search_default_customer":1, 'short_category_name': True}</field>
             <field name="search_view_id" ref="view_res_partner_filter"/>
             <field name="help">A customer is an entity you do business with, like a company or an organization. A customer can have several contacts or addresses which are the people working for this company. You can use the history tab, to follow all transactions related to a customer: sales order, emails, opportunities, claims, etc. If you use the email gateway, the Outlook or the Thunderbird plugin, don't forget to register emails to each contact so that the gateway will automatically attach incoming emails to the right partner.</field>
         </record>