Skip to content

[16.0][MIG] partner_country_lang: Migration to 16.0. - #2240

Open
lfreeke wants to merge 7 commits into
OCA:16.0from
Therp:16.0-mig-partner_country_lang
Open

[16.0][MIG] partner_country_lang: Migration to 16.0.#2240
lfreeke wants to merge 7 commits into
OCA:16.0from
Therp:16.0-mig-partner_country_lang

Conversation

@lfreeke

@lfreeke lfreeke commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@lfreeke lfreeke changed the title 16.0 mig partner country lang [16.0][MIG] partner country lang Dec 18, 2025

@luisDIXMIT luisDIXMIT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested on runboat and LGTM!

@luisDIXMIT

Copy link
Copy Markdown

The commit name must be [MIG] partner_country_lang: Migration to 16.0 as this is a migration not an improvement.

By other hand, the PR title must be [16.0] [MIG] partner_country_lang without spaces to find easier.

@marcos-mendez marcos-mendez left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated Review -- Tests Failed

1. Root Cause

The test failure is due to a database connection error (Connection to the database failed) during the Odoo startup, which prevents the test suite from running. This is not a code issue in the module itself but a test environment configuration problem.

2. Suggested Fix

The error occurs before any module code is executed, indicating an infrastructure or test setup issue. Ensure that:

  • The database service (postgres.runboat-infra.svc.cluster.local) is reachable.
  • The test database is correctly initialized.
  • The odoo.conf or environment variables are properly configured for the test run.

This is not a code fix, but a test environment remediation.

3. Additional Code Issues

None found in the provided diffs. The code follows OCA patterns:

  • _adjust_lang_by_country is a valid extension hook.
  • @api.onchange and create/write overrides are standard.
  • Use of _lang_get is appropriate.

4. Test Improvements

Add tests covering:

  • _adjust_lang_by_country behavior in create and write.
  • _onchange_country_id logic when country_id is changed.
  • Edge cases:
    • Partner created without country_id or lang.
    • Partner with lang already set — should not be overridden.
    • country_id changed to one with no language defined.

Suggested test pattern:

def test_create_partner_with_country_lang(self):
    country = self.env['res.country'].create({'name': 'Test Country', 'lang': 'es_ES'})
    partner = self.env['res.partner'].create({
        'name': 'Test Partner',
        'country_id': country.id,
    })
    self.assertEqual(partner.lang, 'es_ES')

def test_write_partner_country_lang(self):
    country = self.env['res.country'].create({'name': 'Test Country', 'lang': 'es_ES'})
    partner = self.env['res.partner'].create({
        'name': 'Test Partner',
        'country_id': False,
    })
    partner.write({'country_id': country.id})
    self.assertEqual(partner.lang, 'es_ES')

Use TransactionCase for tests involving database changes, as shown in the existing test file.


⏰ This PR has been open for 89 days.
💤 Last activity was 65 days ago.

Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)


Reciprocal Review Request

Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):

My open PRs across OCA:

Reviewing each other's work helps the whole community move forward. Thank you!


Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code and functional review LGTM!

@BhaveshHeliconia

Copy link
Copy Markdown
Contributor

@lfreeke Could you please change the title from [16.0][MIG] partner country lang to [16.0][MIG] partner_country_lang: Migration to 16.0.

@lfreeke lfreeke changed the title [16.0][MIG] partner country lang [16.0][MIG] partner_country_lang: Migration to 16.0. Jun 2, 2026
@lfreeke

lfreeke commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

@lfreeke Could you please change the title from [16.0][MIG] partner country lang to [16.0][MIG] partner_country_lang: Migration to 16.0.

Done

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.

8 participants