Skip to content

Commit

Permalink
[MIG] l10n_es_partner: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Javiobcn committed Feb 19, 2024
1 parent 20e14c3 commit d2212d2
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 24 deletions.
3 changes: 3 additions & 0 deletions l10n_es_partner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ Contributors
- Ismael Calvo <[email protected]>
- Carlos Dauden <[email protected]>
- Manuel Regidor <[email protected]>
- `APSL <https://apsl.tech>`__:

- Javier Antó <[email protected]>

Maintainers
-----------
Expand Down
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": "16.0.2.1.0",
"version": "17.0.1.0.0",
"author": "ZikZak," "Acysos," "Tecnativa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-spain",
"category": "Localisation/Europe",
Expand Down
21 changes: 10 additions & 11 deletions l10n_es_partner/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@ class ResPartner(models.Model):
display_name = fields.Char(compute="_compute_display_name")

@api.depends("comercial")
@api.depends_context("no_display_commercial")
def _compute_display_name(self):
return super()._compute_display_name()

def _get_name(self):
name_pattern = (
self.env["ir.config_parameter"]
.sudo()
.get_param("l10n_es_partner.name_pattern", default="")
)
origin = super()._get_name()
if (
self.env.context.get("no_display_commercial", False)
or not name_pattern
or not self.comercial
):
return origin
return name_pattern % {"name": origin, "comercial_name": self.comercial}
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,
}

@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 @@ -5,3 +5,5 @@
- Ismael Calvo \<<[email protected]>\>
- Carlos Dauden \<<[email protected]>\>
- Manuel Regidor \<<[email protected]>\>
- [APSL](https://apsl.tech):
- Javier Antó \<<[email protected]>\>
4 changes: 4 additions & 0 deletions l10n_es_partner/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li>Ismael Calvo &lt;<a class="reference external" href="mailto:ismael.calvo&#64;factorlibre.com">ismael.calvo&#64;factorlibre.com</a>&gt;</li>
<li>Carlos Dauden &lt;<a class="reference external" href="mailto:carlos.dauden&#64;tecnativa.com">carlos.dauden&#64;tecnativa.com</a>&gt;</li>
<li>Manuel Regidor &lt;<a class="reference external" href="mailto:manuel.regidor&#64;sygel.es">manuel.regidor&#64;sygel.es</a>&gt;</li>
<li><a class="reference external" href="https://apsl.tech">APSL</a>:<ul>
<li>Javier Antó &lt;<a class="reference external" href="mailto:janto&#64;apsl.net">janto&#64;apsl.net</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
11 changes: 9 additions & 2 deletions l10n_es_partner/tests/test_l10n_es_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ def test_name(self):
self.assertEqual(partner2.display_name, "Nombre comercial (Empresa de prueba)")
partner2.write({"comercial": "Nuevo nombre"})
self.assertEqual(partner2.display_name, "Nuevo nombre (Empresa de prueba)")
names = dict(partner2.with_context(no_display_commercial=True).name_get())
names = dict(
[
(
partner2.id,
partner2.with_context(no_display_commercial=True).display_name,
)
]
)
self.assertEqual(names.get(partner2.id), "Empresa de prueba")
names = dict(partner2.name_get())
names = dict([(partner2.id, partner2.display_name)])
self.assertEqual(names.get(partner2.id), "Nuevo nombre (Empresa de prueba)")
4 changes: 2 additions & 2 deletions l10n_es_partner/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<field
name="comercial"
placeholder="Trade name"
attrs="{'invisible': [('is_company','=', False)]}"
invisible="not is_company"
/>
</field>
</field>
Expand All @@ -21,7 +21,7 @@
<field
name="comercial"
placeholder="Trade name"
attrs="{'invisible': [('is_company','=', False)]}"
invisible="not is_company"
/>
</field>
</field>
Expand Down
7 changes: 4 additions & 3 deletions l10n_es_partner/wizard/l10n_es_partner_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def import_local(self):
path = os.path.join("l10n_es_partner", "wizard", "data_banks.xml")
with tools.file_open(path) as fp:
tools.convert_xml_import(
self._cr, "l10n_es_partner", fp, {}, "init", noupdate=True
self.env, "l10n_es_partner", fp, {}, "init", noupdate=True
)
return res

Expand All @@ -36,7 +36,7 @@ def execute(self):
try:
response = requests.get(
"https://www.bde.es/f/webbde/SGE/regis/REGBANESP_CONESTAB_A.xls",
timeout=5,
timeout=10,
)
response.raise_for_status()
src_file.write(response.content)
Expand All @@ -46,6 +46,7 @@ def execute(self):
requests.exceptions.HTTPError,
requests.exceptions.ConnectTimeout,
requests.exceptions.ReadTimeout,
requests.exceptions.ConnectionError,
):
# BDE is forbidding on certain conditions to get the file, so we use a
# local file. Latest update: 2023-10-07
Expand All @@ -56,7 +57,7 @@ def execute(self):
# Generate XML and import it
gen_bank_data_xml(src_file_name, dest_file.name)
tools.convert_xml_import(
self._cr, "l10n_es_partner", dest_file.name, {}, "init", noupdate=True
self.env, "l10n_es_partner", dest_file.name, {}, "init", noupdate=True
)
os.remove(src_file.name)
os.remove(dest_file.name)
8 changes: 3 additions & 5 deletions l10n_es_partner/wizard/l10n_es_partner_wizard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<attribute name="string">Import spanish bank data</attribute>
</form>
<separator position="replace">
<group attrs="{'invisible': [('import_fail', '=', True)]}">
<group invisible="import_fail">
<p
colspan="2"
>This wizard will import spanish bank data. You can choose to import it from:</p>
Expand All @@ -29,7 +29,7 @@
<label
colspan="2"
for="import_fail"
attrs="{'invisible': [('import_fail', '=', False)]}"
invisible="not import_fail"
string="Something has failed importing data from Internet. You will need to import local data instead."
/>
</separator>
Expand All @@ -42,9 +42,7 @@
</button>
<button name="action_next" position="attributes">
<attribute name="string">Import from Internet</attribute>
<attribute
name="attrs"
>{'invisible': [('import_fail', '=', True)]}</attribute>
<attribute name="invisible">import_fail</attribute>
</button>
</data>
</field>
Expand Down

0 comments on commit d2212d2

Please sign in to comment.