Skip to content
Snippets Groups Projects
Commit 728e2387 authored by fw-bot's avatar fw-bot
Browse files

[FIX] base: impossible to change contact name format


- Create a sales order for a company with a contact name.
- Click the Preview button.
- The company and contact names appear on the same line, only separated by a
comma.

Before this commit:

it's not possible to easily override this behavior.

After this commit:

it's possible to override `Partner._get_contact_name` to change the format of
contact name.

Beware that this method is used in `_get_name` which is called from various
places. A check on the context may be necessary.

closes odoo/odoo#38712

Opw: 2077294
X-original-commit: 0b8f3f93a2cb05cc9c940964fe80acd23b86b8a0
Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 1c1b440a
No related branches found
No related tags found
No related merge requests found
......@@ -615,6 +615,9 @@ class Partner(models.Model):
'target': 'new',
'flags': {'form': {'action_buttons': True}}}
def _get_contact_name(self, partner, name):
return "%s, %s" % (partner.commercial_company_name or partner.sudo().parent_id.name, name)
def _get_name(self):
""" Utility method to allow name_get to be overrided without re-browse the partner """
partner = self
......@@ -624,7 +627,7 @@ class Partner(models.Model):
if not name and partner.type in ['invoice', 'delivery', 'other']:
name = dict(self.fields_get(['type'])['type']['selection'])[partner.type]
if not partner.is_company:
name = "%s, %s" % (partner.commercial_company_name or partner.sudo().parent_id.name, name)
name = self._get_contact_name(partner, name)
if self._context.get('show_address_only'):
name = partner._display_address(without_company=True)
if self._context.get('show_address'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment