Skip to content

[18.0][FIX] partner_firstname: res.partner name_create("") fails#2050

Open
amh-mw wants to merge 1 commit intoOCA:18.0from
amh-mw:18.0-partner_firstname-name_create
Open

[18.0][FIX] partner_firstname: res.partner name_create("") fails#2050
amh-mw wants to merge 1 commit intoOCA:18.0from
amh-mw:18.0-partner_firstname-name_create

Conversation

@amh-mw
Copy link
Copy Markdown
Member

@amh-mw amh-mw commented May 1, 2025

The name field constraint in core Odoo only requires that name IS NOT NULL, allowing an empty string.

This causes unit tests to fail for the main Odoo mail module:

2025-10-05 17:03:43,999 1 ERROR odoo odoo.addons.mail.tests.test_res_partner: ERROR: Subtest TestPartner.test_name_create_corner_cases (sample='', login='admin')
Traceback (most recent call last):
  File "<decorator-gen-130>", line 2, in test_name_create_corner_cases
  File "/usr/lib/python3/dist-packages/odoo/tests/common.py", line 2344, in _users
    func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/mail/tests/test_res_partner.py", line 508, in test_name_create_corner_cases
    self.env['res.partner'].name_create(sample)[0]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/res_partner.py", line 937, in name_create
    partner = self.create(create_values)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-174>", line 2, in create
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 497, in _model_create_multi
    return create(self, [arg])
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/src/metricwise/oca/partner-contact/partner_firstname/models/res_partner.py", line 84, in create
    ).create([vals])
      ^^^^^^^^^^^^^^
  File "<decorator-gen-23>", line 2, in create
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 498, in _model_create_multi
    return create(self, arg)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/res_partner.py", line 806, in create
    partners = super().create(vals_list)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-57>", line 2, in create
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 498, in _model_create_multi
    return create(self, arg)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/mail/models/mail_thread.py", line 278, in create
    threads = super(MailThread, self).create(vals_list)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<decorator-gen-0>", line 2, in create
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 498, in _model_create_multi
    return create(self, arg)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 5033, in create
    records = self._create(data_list)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 5291, in _create
    records._validate_fields(name for data in data_list for name in data['stored'])
  File "/usr/lib/python3/dist-packages/odoo/models.py", line 1631, in _validate_fields
    check(self)
  File "/usr/local/src/metricwise/oca/partner-contact/partner_firstname/models/res_partner.py", line 261, in _check_name
    raise exceptions.EmptyNamesError(record, self.env)
odoo.addons.partner_firstname.exceptions.EmptyNamesError: ("Error(s) with partner 818's name.", 'No name is set.')

@amh-mw amh-mw changed the title [FIX] partner_firstname: res.partner name_create("") fails [18.0][FIX] partner_firstname: res.partner name_create("") fails May 1, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 5, 2025

There hasn't been any activity on this pull request in the past 4 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 PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Oct 5, 2025
@amh-mw amh-mw force-pushed the 18.0-partner_firstname-name_create branch 2 times, most recently from 6cfa4c5 to 8a29ad0 Compare October 6, 2025 12:24
@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Oct 12, 2025
@amh-mw amh-mw force-pushed the 18.0-partner_firstname-name_create branch from 8a29ad0 to 8f0d290 Compare October 17, 2025 18:39
@amh-mw amh-mw marked this pull request as draft November 18, 2025 20:26
@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 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 PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 22, 2026
@amh-mw
Copy link
Copy Markdown
Member Author

amh-mw commented Mar 23, 2026

Rebasing, but it seems like #2280 has attempted to solve a similar problem. Investigating...

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 29, 2026
The name field constraint in core Odoo only requires that
name IS NOT NULL, allowing an empty string.
@amh-mw amh-mw force-pushed the 18.0-partner_firstname-name_create branch from 8f0d290 to 7ff99ba Compare April 3, 2026 13:45
@amh-mw amh-mw marked this pull request as ready for review April 3, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant