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

[17.0][MIG] partner_country_lang: Migration to 17.0 #1976

Open
wants to merge 4 commits into
base: 17.0
Choose a base branch
from

Conversation

victoralmau
Copy link
Member

@victoralmau victoralmau commented Feb 5, 2025

Migration to 17.0

@Tecnativa TT54939

victoralmau and others added 3 commits February 5, 2025 17:42
TT38559

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: partner-contact-13.0/partner-contact-13.0-partner_country_lang
Translate-URL: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_country_lang/
[UPD] Update partner_country_lang.pot

[UPD] README.rst

[UPD] README.rst
@pedrobaeza
Copy link
Member

You should convert the onchange to compute and you won't need that dependency switch.

@pedrobaeza
Copy link
Member

/ocabot migration partner_country_lang

@OCA-git-bot OCA-git-bot added this to the 17.0 milestone Feb 5, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Feb 5, 2025
67 tasks
@victoralmau victoralmau force-pushed the 17.0-mig-partner_country_lang branch from f128cca to 8697a6f Compare February 5, 2025 17:02
@victoralmau
Copy link
Member Author

You should convert the onchange to compute and you won't need that dependency switch.

Changes done.

class ResPartner(models.Model):
_inherit = "res.partner"

lang = fields.Selection(compute="_compute_lang")
Copy link
Member

Choose a reason for hiding this comment

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

Always add a comment indicating that this is an override

Suggested change
lang = fields.Selection(compute="_compute_lang")
# Add the compute method on the existing field
lang = fields.Selection(compute="_compute_lang")


@api.depends("country_id")
def _compute_lang(self):
for item in self:
Copy link
Member

Choose a reason for hiding this comment

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

Be preventive if the method already exists in other module:

Suggested change
for item in self:
for item in self:
if hasattr(super(), "_compute_lang"):
super()._compute_lang()

@api.depends("country_id")
def _compute_lang(self):
for item in self:
item.lang = item.country_id.lang or item.lang
Copy link
Member

Choose a reason for hiding this comment

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

Isn't more declarative this way and avoid unneeded assignations?

Suggested change
item.lang = item.country_id.lang or item.lang
if item.country_id.lang:
item.lang = item.country_id.lang

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.

4 participants