[IMP] base: allow the category name to not include the parents if the context requires it

bzr revid: ls@numerigraphe.fr-20111215145604-wu2muv9m9gb9c9h4
This commit is contained in:
Numerigraphe - Lionel Sausin
2011-12-15 15:56:04 +01:00
parent 3ffb9b8134
commit eec9f019f0
2 changed files with 9 additions and 2 deletions
+8 -1
View 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
+1 -1
View File
@@ -505,7 +505,7 @@
<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>