[FIX] base: partner name displayed with unnecessary comma
Before this commit: when partner is only created with name(i.e. without address) and when 'address_inline' is passed in context then partner name shows with unnecessary commas. After this commit: partner name will not have unncessary commas, as we removes unncessary '\n' in case of 'address_inline' passed in context. task-2502597 closes odoo/odoo#72869 X-original-commit: c08082d89782b7675e8e649cba15ca9e03e40077 Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
This commit is contained in:
@@ -723,7 +723,8 @@ class Partner(models.Model):
|
||||
if self._context.get('partner_show_db_id'):
|
||||
name = "%s (%s)" % (name, partner.id)
|
||||
if self._context.get('address_inline'):
|
||||
name = name.replace('\n', ', ')
|
||||
splitted_names = name.split("\n")
|
||||
name = ", ".join([n for n in splitted_names if n.strip()])
|
||||
if self._context.get('show_email') and partner.email:
|
||||
name = "%s <%s>" % (name, partner.email)
|
||||
if self._context.get('html_format'):
|
||||
|
||||
@@ -19,6 +19,22 @@ class TestPartner(TransactionCase):
|
||||
ns_res = self.env['res.partner'].name_search('Vlad', args=[('user_ids.email', 'ilike', 'vlad')])
|
||||
self.assertEqual(set(i[0] for i in ns_res), set(test_user.partner_id.ids))
|
||||
|
||||
def test_name_get(self):
|
||||
""" Check name_get on partner, especially with different context
|
||||
Check name_get correctly return name with context. """
|
||||
test_partner_jetha = self.env['res.partner'].create({'name': 'Jethala', 'street': 'Powder gali', 'street2': 'Gokuldham Society'})
|
||||
test_partner_bhide = self.env['res.partner'].create({'name': 'Atmaram Bhide'})
|
||||
|
||||
res_jetha = test_partner_jetha.with_context(show_address=1).name_get()
|
||||
self.assertEqual(res_jetha[0][1], "Jethala\nPowder gali\nGokuldham Society\n \n", "name should contain comma separated name and address")
|
||||
res_bhide = test_partner_bhide.with_context(show_address=1).name_get()
|
||||
self.assertEqual(res_bhide[0][1], "Atmaram Bhide\n \n", "name should contain only name if address is not available, without extra commas")
|
||||
|
||||
res_jetha = test_partner_jetha.with_context(show_address=1, address_inline=1).name_get()
|
||||
self.assertEqual(res_jetha[0][1], "Jethala, Powder gali, Gokuldham Society", "name should contain comma separated name and address")
|
||||
res_bhide = test_partner_bhide.with_context(show_address=1, address_inline=1).name_get()
|
||||
self.assertEqual(res_bhide[0][1], "Atmaram Bhide", "name should contain only name if address is not available, without extra commas")
|
||||
|
||||
def test_company_change_propagation(self):
|
||||
""" Check propagation of company_id across children """
|
||||
User = self.env['res.users']
|
||||
|
||||
Reference in New Issue
Block a user