← Back to team overview

openerp-community-reviewer team mailing list archive

lp:~camptocamp/partner-contact-management/remove_trailing_space_partner_mdh into lp:partner-contact-management

 

Matthieu Dietrich @ camptocamp has proposed merging lp:~camptocamp/partner-contact-management/remove_trailing_space_partner_mdh into lp:partner-contact-management.

Commit message:
[FIX] remove trailing space from display name if only the lastname is defined

Requested reviews:
  Partner and Contact Core Editors (partner-contact-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/partner-contact-management/remove_trailing_space_partner_mdh/+merge/197400

The display name is the one used as a search criteria, and if only the last name is defined (i.e. for a parent company), a space was trailing after the name.

This led to issues with searches in the invoice view, for example; the operator is 'child-of', which is defined as '=ilike %<name>%'. The child's name is "<parent's name>, <child's name>" so the ilike failed because of the trailing space.
-- 
https://code.launchpad.net/~camptocamp/partner-contact-management/remove_trailing_space_partner_mdh/+merge/197400
Your team Partner and Contact Core Editors is requested to review the proposed merge of lp:~camptocamp/partner-contact-management/remove_trailing_space_partner_mdh into lp:partner-contact-management.
=== modified file 'firstname_display_name_trigger/res_partner.py'
--- firstname_display_name_trigger/res_partner.py	2013-05-24 11:42:19 +0000
+++ firstname_display_name_trigger/res_partner.py	2013-12-02 15:17:32 +0000
@@ -37,8 +37,10 @@
             ids = [ids]
         res = []
         for record in self.browse(cr, uid, ids, context=context):
-            name = '%s %s'%(record.lastname if record.lastname else u"",
-                            record.firstname if record.firstname else u"")
+            name = '%s%s%s' % (record.lastname if record.lastname else u"",
+                               u" " if record.firstname and record.lastname
+                                    else u"",
+                               record.firstname if record.firstname else u"")
             if record.parent_id and not record.is_company:
                 name =  "%s, %s" % (record.parent_id.name, name)
             if context.get('show_address'):


Follow ups