OCA / partner-contact

Odoo Partner and Contact related addons
GNU Affero General Public License v3.0
206 stars 846 forks source link

[16.0] partner_firstname cannot be installed, if the system contains a contact with an empty name #1677

Open mohs8421 opened 7 months ago

mohs8421 commented 7 months ago

When trying to install this module, I already get the following error:

RPC_ERROR Odoo Server Error Traceback (most recent call last): … File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 90, in new odoo.modules.load_modules(registry, force_demo, status, update_module) File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 488, in load_modules processed_modules += load_marked_modules(cr, graph, File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 372, in load_marked_modules loaded, processed = load_module_graph( File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 249, in load_module_graph getattr(py_module, post_init)(cr, registry) File "partner_firstname/hooks.py", line 9, in post_init_hook env["res.partner"]._install_partner_firstname() File "partner_firstname/models/res_partner.py", line 220, in _install_partner_firstname records._inverse_name() File "partner_firstname/models/res_partner.py", line 193, in _inverse_name record.lastname = parts["lastname"] File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1325, in set records.write({self.name: write_value}) … File "/usr/lib/python3/dist-packages/odoo/models.py", line 3798, in write real_recs._validate_fields(vals, inverse_fields) File "/usr/lib/python3/dist-packages/odoo/models.py", line 1359, in _validate_fields check(self) File "partner_firstname/models/res_partner.py", line 206, in _check_name raise exceptions.EmptyNamesError(record) odoo.addons.partner_firstname.exceptions.EmptyNamesError: ('Fehler beim Namen des Partners 1270 .', 'Es ist kein Name eingetragen.')

It might be an issue referring to the general misconceptions about names also

  1. People have names.

Besides the edgecases, it might also be relevant for the system to be aware that the information about the firstname might simply be missing and only other details might be available.

Module

partner_firstname

To Reproduce

Affected versions: 16.0

Steps to reproduce the behavior:

  1. Create a Contact without a name, for example with only a phone number or an email
  2. Try to install the module

Expected behavior The module should be installable

mohs8421 commented 7 months ago

In my local system I resolved this issue with the following small change:

diff --git a/partner_firstname/models/res_partner.py b/partner_firstname/models/res_partner.py
index d933e8055..64bb9966d 100644
--- a/partner_firstname/models/res_partner.py
+++ b/partner_firstname/models/res_partner.py
@@ -214,7 +214,7 @@ class ResPartner(models.Model):
         correctly into the database. This can be called later too if needed.
         """
         # Find records with empty firstname and lastname
-        records = self.search([("firstname", "=", False), ("lastname", "=", False)])
+        records = self.search([("firstname", "=", False), ("lastname", "=", False), ("name", "!=", "")])

         # Force calculations there
         records._inverse_name()
mohs8421 commented 6 months ago

I have to wonder if this repository is still maintained? I provided a bug report and a fix, and there is no reaction at all.

simahawk commented 6 months ago

@mohs8421 thanks for your contrib.

I have to wonder if this repository is still maintained? I provided a bug report and a fix, and there is no reaction at all.

There are plenty of things to maintain as we have more than 230 repos and more than 5k modules :wink:

I'm not a maintainer of that module but I'll have a look at your PR.

github-actions[bot] commented 22 hours ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

mohs8421 commented 3 hours ago

so how does contributing work here? Things don't get reviewed or merged and bots automatically tend to close contributions if they are left unattended? Isn't this behaviour actually harming for contributions in general?