-
-
Notifications
You must be signed in to change notification settings - Fork 871
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
base: 17.0
Are you sure you want to change the base?
Conversation
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
You should convert the onchange to compute and you won't need that dependency switch. |
/ocabot migration partner_country_lang |
f128cca
to
8697a6f
Compare
Changes done. |
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
lang = fields.Selection(compute="_compute_lang") |
There was a problem hiding this comment.
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
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: |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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?
item.lang = item.country_id.lang or item.lang | |
if item.country_id.lang: | |
item.lang = item.country_id.lang |
Migration to 17.0
@Tecnativa TT54939