Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] partner_contact_department: make display name lang-aware #2023

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

yajo
Copy link
Member

@yajo yajo commented Mar 5, 2025

Yet another iteration over #2009.

display_name wasn't translatable, but name was. Thus, stored record order was always on English. Now, if department names are translated and the user switches to another language, the order the user will see will match the language it is displaying.

Another fix is that now, when changing a parent department name name, children display names will change too.

I took the chance to apply some anti-flaky-tests good practices in current test suite (apart from increasing coverage to cover these new cases).

@moduon MT-8760

@yajo yajo force-pushed the 16.0-pcd-order_by_name branch 2 times, most recently from 1ca4276 to fccc715 Compare March 5, 2025 11:18
Copy link

@fcvalgar fcvalgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional review,

LGTM, thank you @yajo.

image

image

Copy link

@fcvalgar fcvalgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an error with the creation of the department with the last entered change of the display_name.

Traceback (most recent call last):
  File "/opt/odoo/odoo/http.py", line 1658, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/opt/odoo/odoo/service/model.py", line 152, in retrying
    result = func()
  File "/opt/odoo/odoo/http.py", line 1686, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoo/odoo/http.py", line 1890, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoo/odoo/http.py", line 734, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoo/addons/web/controllers/dataset.py", line 43, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/addons/web/controllers/dataset.py", line 34, in _call_kw
    return call_kw(Model, method, args, kwargs)
  File "/opt/odoo/odoo/api.py", line 484, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/odoo/api.py", line 469, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/odoo/models.py", line 6665, in onchange
    snapshot1 = Snapshot(record, nametree)
  File "/opt/odoo/odoo/models.py", line 6425, in __init__
    self.fetch(name)
  File "/opt/odoo/odoo/models.py", line 6435, in fetch
    self[name] = record[name]
  File "/opt/odoo/odoo/models.py", line 5991, in __getitem__
    return self._fields[key].__get__(self, self.env.registry[self._name])
  File "/opt/odoo/odoo/fields.py", line 1158, in __get__
    self.recompute(record)
  File "/opt/odoo/odoo/fields.py", line 1382, in recompute
    apply_except_missing(self.compute_value, recs)
  File "/opt/odoo/odoo/fields.py", line 1355, in apply_except_missing
    func(records)
  File "/opt/odoo/odoo/fields.py", line 1404, in compute_value
    records._compute_field_value(self)
  File "/opt/odoo/odoo/models.py", line 4260, in _compute_field_value
    fields.determine(field.compute, self)
  File "/opt/odoo/odoo/fields.py", line 98, in determine
    return needle(*args)
  File "/mnt/data/odoo-addons-dir/partner_contact_department/models/res_partner.py", line 37, in _compute_display_name
    results[lang] = super(ResPartnerDepartment, _self)._compute_display_name()
  File "/opt/odoo/odoo/models.py", line 1546, in _compute_display_name
    names = dict(self.name_get())
  File "/mnt/data/odoo-addons-dir/partner_contact_department/models/res_partner.py", line 43, in name_get
    map(int, "/".join(rec.parent_path.strip("/") for rec in self).split("/"))
  File "/mnt/data/odoo-addons-dir/partner_contact_department/models/res_partner.py", line 43, in <genexpr>
    map(int, "/".join(rec.parent_path.strip("/") for rec in self).split("/"))
AttributeError: 'bool' object has no attribute 'strip'

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPC_ERROR
        at makeErrorFromResponse (http://oca-partner-contact-16-0-pr2023-fccc7151fffd.runboat.odoo-community.org/web/assets/459-60b098f/web.assets_backend.min.js:1002:163)
        at XMLHttpRequest.<anonymous> (http://oca-partner-contact-16-0-pr2023-fccc7151fffd.runboat.odoo-community.org/web/assets/459-60b098f/web.assets_backend.min.js:1010:13)

@rafaelbn rafaelbn added this to the 16.0 milestone Mar 5, 2025
@rafaelbn rafaelbn requested a review from Shide March 5, 2025 12:52
Yet another iteration over OCA#2009.

`display_name` wasn't translatable, but `name` was. Thus, stored record order was always on English. Now, if department names are translated and the user switches to another language, the order the user will see will match the language it is displaying.

Another fix is that now, when changing a parent department name name, children display names will change too.

I took the chance to apply some anti-flaky-tests good practices in current test suite (apart from increasing coverage to cover these new cases).

@moduon MT-8760
@yajo yajo force-pushed the 16.0-pcd-order_by_name branch from fccc715 to 49389bb Compare March 5, 2025 14:15
@yajo
Copy link
Member Author

yajo commented Mar 5, 2025

Please @fcvalgar review again.

@yajo yajo requested a review from fcvalgar March 5, 2025 14:15
Copy link

@fcvalgar fcvalgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you @yajo

image

image

@fcvalgar
Copy link

fcvalgar commented Mar 7, 2025

@yajo, Can you check the tests? thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants