Skip to content

[18.0][MIG] users_ldap_populate: Migration to 18.0 - #841

Closed
ap-wtioit wants to merge 57 commits into
OCA:18.0from
ap-wtioit:18.0-mig-users_ldap_populate
Closed

ap-wtioit wants to merge 57 commits into
OCA:18.0from
ap-wtioit:18.0-mig-users_ldap_populate

Conversation

@ap-wtioit

Copy link
Copy Markdown
Contributor

Migration of users_ldap_populate from 17.0 to 18.0

Info @wt-io-it

dreispt and others added 30 commits September 23, 2025 14:38
In order to get visibility on https://www.odoo.com/apps the OCA board has
decided to add the OCA as author of all the addons maintained as part of the
association.
and remove use of deprecated except_orm on the way
* leftovers from old api
* python-ldap does not like Unicode strings
* [MIG] migrate users_ldap_populate to 10.0

Changes include:
 - move views to views folder
 - move models to models folder
 - in views rename openerp to odoo
 - __openerp__.py to __manifest__.py

* [FIX] Add read me to module users_ldap_populate

* [FIX] users_ldap_populate: cleanup manifest file

Cleanup of the author list

* [FIX] users_ldap_populate: More modern copyright in .py files

* [FIX] users_ldap_populate: Update read me

Fixes include:
 - more human module name
 - Fix web links
….0 port (OCA#408)

* [ADD] possibility to deactivate users not found in ldap while populating

* [IMP] search in ldap for every possibly unknown user to be really sure it
actually is not present there

* [FIX] refactoring mistake

* [IMP] don't use self.query() to be sure to be stopped if any error occurs

* [IMP] remove superfluous check as exceptions are not supressed any more

* [FIX] typo in variable name
[FIX] handle unicode characters in search filter
[FIX] search for user's login, not her name

* [FIX] don't pass user_name as assertion_value

* [FIX] don't deactivate users if we got a non-existent ldap configuration

* [FIX] flake8

* [FIX] more flake8

* [FIX] make form usable

* [FIX] name clash between function and field

* [ADD] test
Also various changes to satisfy pylint/flake/travis.
gurneyalex and others added 23 commits September 23, 2025 14:38
Currently translated at 100.0% (21 of 21 strings)

Translation: server-tools-10.0/server-tools-10.0-users_ldap_populate
Translate-URL: https://translation.odoo-community.org/projects/server-tools-10-0/server-tools-10-0-users_ldap_populate/fr/
* [10.0] users_ldap_populate special characters
Without this fix, when hitting the populate button, Odoo failed with:

```
 Odoo Server Error

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 656, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 314, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/opt/odoo/custom/src/odoo/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 698, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 346, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 941, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/auto/addons/web/controllers/main.py", line 966, in call_button
    action = self._call_kw(model, method, args, {})
  File "/opt/odoo/auto/addons/web/controllers/main.py", line 954, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 759, in call_kw
    return _call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 746, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/auto/addons/users_ldap_populate/models/users_ldap.py", line 189, in populate_wizard
    res_id = wizard_obj.create({'ldap_id': self.id}).id
  File "<decorator-gen-155>", line 2, in create
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 461, in _model_create_multi
    return create(self, [arg])
  File "/opt/odoo/auto/addons/users_ldap_populate/models/populate_wizard.py", line 32, in create
    ldap.action_populate()
  File "/opt/odoo/auto/addons/users_ldap_populate/models/users_ldap.py", line 65, in action_populate
    results = self._get_ldap_entry_dicts(conf)
  File "/opt/odoo/auto/addons/users_ldap_populate/models/users_ldap.py", line 128, in _get_ldap_entry_dicts
    ldap_password.encode('utf-8')
  File "/usr/local/lib/python3.7/site-packages/ldap/ldapobject.py", line 382, in simple_bind_s
    msgid = self.simple_bind(who,cred,serverctrls,clientctrls)
  File "/usr/local/lib/python3.7/site-packages/ldap/ldapobject.py", line 376, in simple_bind
    return self._ldap_call(self._l.simple_bind,who,cred,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
  File "/usr/local/lib/python3.7/site-packages/ldap/ldapobject.py", line 263, in _ldap_call
    result = func(*args,**kwargs)
TypeError: argument 1 must be str, not bytes
```
Don't know why the POT hasn't been regenerated.
Currently translated at 100.0% (22 of 22 strings)

Translation: server-auth-16.0/server-auth-16.0-users_ldap_populate
Translate-URL: https://translation.odoo-community.org/projects/server-auth-16-0/server-auth-16-0-users_ldap_populate/it/
Currently translated at 100.0% (22 of 22 strings)

Translation: server-auth-16.0/server-auth-16.0-users_ldap_populate
Translate-URL: https://translation.odoo-community.org/projects/server-auth-16-0/server-auth-16-0-users_ldap_populate/pt_BR/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-auth-17.0/server-auth-17.0-users_ldap_populate
Translate-URL: https://translation.odoo-community.org/projects/server-auth-17-0/server-auth-17-0-users_ldap_populate/
When iterating through the users from LDAP, if the login information
is read in bytes, passing the value in bytes to the psycopg2 library
doesn't work, failing with this error:

```
psycopg2.errors.UndefinedFunction: operator does not exist: text = bytea
LINE 1: SELECT id FROM res_users WHERE lower(login)='...
```

so we need to decode the result before to get a pure string.

TT56992
@ap-wtioit ap-wtioit changed the title 18.0 mig users ldap populate [18.0][MIG] auth_ldap_attribute_sync: Migration to 18.0 Sep 23, 2025
@ap-wtioit ap-wtioit mentioned this pull request Sep 23, 2025
18 of 23 tasks
@ap-wtioit ap-wtioit changed the title [18.0][MIG] auth_ldap_attribute_sync: Migration to 18.0 [18.0][MIG] users_ldap_populate: Migration to 18.0 Sep 23, 2025
@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 Jan 25, 2026
@github-actions github-actions Bot closed this Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.