Skip to content

Commit

Permalink
Merge PR #3879 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by HaraldPanten
  • Loading branch information
OCA-git-bot committed Jan 9, 2025
2 parents 1eb6686 + f00ed26 commit cf56d20
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 25 deletions.
13 changes: 10 additions & 3 deletions l10n_es_partner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Incluye la siguiente funcionalidad:
el nombre comercial de la empresa.
- Añade los campos nombre largo, NIF y web a los bancos.
- Añade los datos de los bancos españoles extraídos del registro
oficial del Banco de España (http://goo.gl/mtx6ic). El asistente
oficial del Banco de España
(`http://goo.gl/mtx6ic <http://goo.gl/mtx6ic>`__). El asistente
realiza la descarga automática de Internet, pero si por cualquier
razón hay algún problema, existe una copia local cuya última
actualización fue el 26/10/2017.
Expand All @@ -50,7 +51,8 @@ Installation
============

Este módulo depende de *base_bank_from_iban* que se encuentra en el
repositorio https://github.com/OCA/community-data-files
repositorio
`https://github.com/OCA/community-data-files <https://github.com/OCA/community-data-files>`__

Configuration
=============
Expand All @@ -72,7 +74,8 @@ para nombre comercial.
Known issues / Roadmap
======================

- Take BICs from https://github.com/PeterNotenboom/SwiftCodes.
- Take BICs from
`https://github.com/PeterNotenboom/SwiftCodes <https://github.com/PeterNotenboom/SwiftCodes>`__.

Bug Tracker
===========
Expand Down Expand Up @@ -108,6 +111,10 @@ Contributors

- Javier Antó <[email protected]>

- `Dixmit <https://www.dixmit.com>`__:

- Enric Tobella

Maintainers
-----------

Expand Down
40 changes: 26 additions & 14 deletions l10n_es_partner/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,33 @@ class ResPartner(models.Model):
@api.depends("comercial")
@api.depends_context("no_display_commercial")
def _compute_display_name(self):
name_pattern = (
self.env["ir.config_parameter"]
.sudo()
.get_param("l10n_es_partner.name_pattern", default="")
)
no_display_commercial = self.env.context.get("no_display_commercial")
for partner in self:
if no_display_commercial or not name_pattern or not partner.comercial:
super(ResPartner, partner)._compute_display_name()
else:
partner.display_name = name_pattern % {
"name": partner.complete_name,
"comercial_name": partner.comercial,
"""
We are enforcing the new context,
because complete name field will remove the context
"""
return super(
ResPartner,
self.with_context(
display_commercial=not self.env.context.get(
"no_display_commercial", False
)
),
)._compute_display_name()

def _get_complete_name(self):
name = super()._get_complete_name()
if self.env.context.get("display_commercial") and self.comercial:
name_pattern = (
self.env["ir.config_parameter"]
.sudo()
.get_param("l10n_es_partner.name_pattern", default="")
)
if name_pattern:
name = name_pattern % {
"name": name,
"comercial_name": self.comercial,
}
return True
return name

@api.model
def _commercial_fields(self):
Expand Down
2 changes: 2 additions & 0 deletions l10n_es_partner/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
- Manuel Regidor \<<[email protected]>\>
- [APSL](https://apsl.tech):
- Javier Antó \<<[email protected]>\>
- [Dixmit](https://www.dixmit.com):
- Enric Tobella
24 changes: 17 additions & 7 deletions l10n_es_partner/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -377,7 +378,8 @@ <h1 class="title">Adaptación de los clientes, proveedores y bancos para España
el nombre comercial de la empresa.</li>
<li>Añade los campos nombre largo, NIF y web a los bancos.</li>
<li>Añade los datos de los bancos españoles extraídos del registro
oficial del Banco de España (<a class="reference external" href="http://goo.gl/mtx6ic">http://goo.gl/mtx6ic</a>). El asistente
oficial del Banco de España
(<a class="reference external" href="http://goo.gl/mtx6ic">http://goo.gl/mtx6ic</a>). El asistente
realiza la descarga automática de Internet, pero si por cualquier
razón hay algún problema, existe una copia local cuya última
actualización fue el 26/10/2017.</li>
Expand All @@ -400,7 +402,8 @@ <h1 class="title">Adaptación de los clientes, proveedores y bancos para España
<div class="section" id="installation">
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<p>Este módulo depende de <em>base_bank_from_iban</em> que se encuentra en el
repositorio <a class="reference external" href="https://github.com/OCA/community-data-files">https://github.com/OCA/community-data-files</a></p>
repositorio
<a class="reference external" href="https://github.com/OCA/community-data-files">https://github.com/OCA/community-data-files</a></p>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
Expand All @@ -419,7 +422,8 @@ <h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Take BICs from <a class="reference external" href="https://github.com/PeterNotenboom/SwiftCodes">https://github.com/PeterNotenboom/SwiftCodes</a>.</li>
<li>Take BICs from
<a class="reference external" href="https://github.com/PeterNotenboom/SwiftCodes">https://github.com/PeterNotenboom/SwiftCodes</a>.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
Expand Down Expand Up @@ -454,12 +458,18 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li>Javier Antó &lt;<a class="reference external" href="mailto:janto&#64;apsl.net">janto&#64;apsl.net</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.dixmit.com">Dixmit</a>:<ul>
<li>Enric Tobella</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
16 changes: 15 additions & 1 deletion l10n_es_partner/tests/test_l10n_es_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,23 @@ def test_name(self):
"l10n_es_partner.name_pattern", "%(comercial_name)s (%(name)s)"
)
partner2 = self.env["res.partner"].create(
{"name": "Empresa de prueba", "comercial": "Nombre comercial"}
{
"name": "Empresa de prueba",
"comercial": "Nombre comercial",
"street": "My street",
}
)
self.assertEqual(partner2.display_name, "Nombre comercial (Empresa de prueba)")
self.assertEqual(partner2.complete_name, "Empresa de prueba")
self.assertEqual(
partner2.with_context(show_address=True).display_name,
"Nombre comercial (Empresa de prueba)\nMy street",
)
# We will enforce the computation, but nothing should change
partner2.with_context(
show_address=True, display_commercial=True
)._compute_complete_name()
self.assertEqual(partner2.complete_name, "Empresa de prueba")
partner2.write({"comercial": "Nuevo nombre"})
self.assertEqual(partner2.display_name, "Nuevo nombre (Empresa de prueba)")
names = dict(
Expand Down

0 comments on commit cf56d20

Please sign in to comment.