[IMP] base: display db ID along with name in partner merge wizard
Before this commit: When merging the contacts, chances are there that the name of records being merged are exactly same, and so we might not be able to distinguish them and so can not tell for sure that which records are being merged to which destination record. After this commit: In the 'Destination Contact' field, now we also show ID of the partner along with the name, so that end user can easily distinguish between them. For this, we pass 'partner_show_db_id' on the context for that field from view, allowing us to get expected result from the name_get by using this context key. Task ID-2323060 closes odoo/odoo#66026 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
committed by
Thibault Delavallée
parent
52df97e4f3
commit
eca92a97be
@@ -662,6 +662,8 @@ class Partner(models.Model):
|
||||
name = name + "\n" + partner._display_address(without_company=True)
|
||||
name = name.replace('\n\n', '\n')
|
||||
name = name.replace('\n\n', '\n')
|
||||
if self._context.get('partner_show_db_id'):
|
||||
name = "%s (%s)" % (name, partner.id)
|
||||
if self._context.get('address_inline'):
|
||||
name = name.replace('\n', ', ')
|
||||
if self._context.get('show_email') and partner.email:
|
||||
|
||||
@@ -40,3 +40,12 @@ class TestPartner(TransactionCase):
|
||||
|
||||
with self.assertRaises(UserError, msg="You should not be able to update the company_id of the partner company if the linked user of a child partner is not an allowed to be assigned to that company"), self.cr.savepoint():
|
||||
test_partner_company.write({'company_id': company_2.id})
|
||||
|
||||
def test_partner_merge_wizard_dst_partner_id(self):
|
||||
""" Check that dst_partner_id in merge wizard displays id along with partner name """
|
||||
test_partner = self.env['res.partner'].create({'name': 'Radu the Handsome'})
|
||||
expected_partner_name = '%s (%s)' % (test_partner.name, test_partner.id)
|
||||
|
||||
partner_merge_wizard = self.env['base.partner.merge.automatic.wizard'].with_context(
|
||||
{'partner_show_db_id': True, 'default_dst_partner_id': test_partner}).new()
|
||||
self.assertEqual(partner_merge_wizard.dst_partner_id.display_name, expected_partner_name, "'Destination Contact' name should contain db ID in brackets")
|
||||
|
||||
@@ -55,7 +55,11 @@
|
||||
You can remove contacts from this list to avoid merging them.
|
||||
</p>
|
||||
<group col="2">
|
||||
<field name="dst_partner_id" domain="[('id', 'in', partner_ids or False)]" attrs="{'required': [('state', '=', 'selection')]}"/>
|
||||
<field name="dst_partner_id"
|
||||
domain="[('id', 'in', partner_ids or False)]"
|
||||
attrs="{'required': [('state', '=', 'selection')]}"
|
||||
context="{'partner_show_db_id': True}"
|
||||
options="{'always_reload': True}"/>
|
||||
</group>
|
||||
<field name="partner_ids" nolabel="1">
|
||||
<tree string="Partners">
|
||||
|
||||
Reference in New Issue
Block a user