Skip to content

Commit

Permalink
Merge PR OCA#1882 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by rvalyi
  • Loading branch information
OCA-git-bot committed Nov 3, 2024
2 parents f53d667 + dab8348 commit 460677f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions partner_display_name_line_break/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,22 @@ class ResPartner(models.Model):
"show_vat",
"lang",
"_two_lines_partner_address",
"_keep_partner_address_type",
)
def _compute_display_name(self): # pylint: disable=W8110
super()._compute_display_name()
if self.env.context.get("_two_lines_partner_address"):
for partner in self:
# Do not split on two lines if name is empty as it would display
# the address type on a new line in the report.
# This happens because Odoo splits the display_name on \n character
# and discards the first element to get the address from the
# display_name. In which case, the address type would appear as
# part of the address.
if not partner.name and not self.env.context.get(
"_keep_partner_address_type"
):
continue
displayed_types = partner._complete_name_displayed_types
type_description = dict(
partner._fields["type"]._description_selection(partner.env)
Expand Down
6 changes: 6 additions & 0 deletions partner_display_name_line_break/tests/test_res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,11 @@ def test_get_name(self):
# Partner without a name.
self.assertEqual(
self.child_partner_no_name.display_name,
"Test Company Name, Invoice Address",
)
self.assertEqual(
self.child_partner_no_name.with_context(
_keep_partner_address_type=True
).display_name,
"Test Company Name\nInvoice Address",
)

0 comments on commit 460677f

Please sign in to comment.