Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][FIX] l10n_es_partner: Show comercial #4029

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n_es_partner/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{
"name": "Adaptación de los clientes, proveedores y bancos para España",
"version": "17.0.1.0.1",
"version": "17.0.2.0.0",
"author": "ZikZak," "Acysos," "Tecnativa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-spain",
"category": "Localisation/Europe",
Expand Down
8 changes: 8 additions & 0 deletions l10n_es_partner/migrations/17.0.2.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
partners = env["res.partner"].search([("comercial", "!=", False)])
for partner in partners:
partner._compute_complete_name()
11 changes: 10 additions & 1 deletion l10n_es_partner/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class ResPartner(models.Model):
comercial = fields.Char("Trade name", size=128, index="trigram")
display_name = fields.Char(compute="_compute_display_name")

@api.depends("comercial")
def _compute_complete_name(self):
return super()._compute_complete_name()

@api.depends("comercial")
@api.depends_context("no_display_commercial")
def _compute_display_name(self):
Expand All @@ -30,7 +34,12 @@ def _compute_display_name(self):

def _get_complete_name(self):
name = super()._get_complete_name()
if self.env.context.get("display_commercial") and self.comercial:
display_commercial = self.env.context.get("display_commercial")
if not display_commercial:
display_commercial = not self.env.context.get(
"no_display_commercial", False
)
if display_commercial and self.comercial:
name_pattern = (
self.env["ir.config_parameter"]
.sudo()
Expand Down
4 changes: 2 additions & 2 deletions l10n_es_partner/tests/test_l10n_es_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_name(self):
}
)
self.assertEqual(partner2.display_name, "Nombre comercial (Empresa de prueba)")
self.assertEqual(partner2.complete_name, "Empresa de prueba")
self.assertEqual(partner2.complete_name, "Nombre comercial (Empresa de prueba)")
self.assertEqual(
partner2.with_context(show_address=True).display_name,
"Nombre comercial (Empresa de prueba)\nMy street",
Expand All @@ -81,7 +81,7 @@ def test_name(self):
partner2.with_context(
show_address=True, display_commercial=True
)._compute_complete_name()
self.assertEqual(partner2.complete_name, "Empresa de prueba")
self.assertEqual(partner2.complete_name, "Nombre comercial (Empresa de prueba)")
partner2.write({"comercial": "Nuevo nombre"})
self.assertEqual(partner2.display_name, "Nuevo nombre (Empresa de prueba)")
names = dict(
Expand Down
Loading