diff --git a/partner_contact_lang/README.rst b/partner_contact_lang/README.rst
index 16e211b39..5902a95e0 100644
--- a/partner_contact_lang/README.rst
+++ b/partner_contact_lang/README.rst
@@ -32,11 +32,11 @@ This module fills this gap, and also provides other facilities for the
contact language management:
#. Put the language of the parent company when the contact doesn't have a
-language and this parent company is assigned.
+ language and this parent company is assigned.
#. When the company changes the language, it fills with the same language all
-the contacts that don't have any.
+ the contacts that don't have any.
#. Show the language in the inner narrowed Contact form and
-set the new conctact with a different language if needed.
+ set the new conctact with a different language if needed.
#. Search and also group contacts by their language.
**Table of contents**
diff --git a/partner_contact_lang/models/res_partner.py b/partner_contact_lang/models/res_partner.py
index acbab0db3..b28f64d4f 100644
--- a/partner_contact_lang/models/res_partner.py
+++ b/partner_contact_lang/models/res_partner.py
@@ -1,5 +1,5 @@
-# Copyright 2016 Tecnativa - Pedro M. Baeza
-# Copyright 2017 Tecnativa - Vicent Cubells
+# Copyright 2016-2020 Tecnativa - Pedro M. Baeza
+# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
@@ -28,13 +28,17 @@ class ResPartner(models.Model):
@api.onchange("parent_id")
def onchange_parent_id(self):
"""Change language if the parent company changes and there's no
- language defined yet"""
+ language defined yet.
+
+ A special case is made for virtual records, where default lang value
+ is assigned at startup, so we always overwrite language in that case.
+ """
res = super(ResPartner, self).onchange_parent_id()
if (
- self.parent_id
- and self.parent_id != self
- and not self.lang
- and self.parent_id.lang
+ self.parent_id.lang and (
+ not self.lang or
+ (isinstance(self.id, models.NewId) and not self._origin)
+ ) and self.parent_id.lang != self.lang
):
self.lang = self.parent_id.lang
return res
diff --git a/partner_contact_lang/readme/DESCRIPTION.rst b/partner_contact_lang/readme/DESCRIPTION.rst
index 85d1e6d78..1df4a4755 100644
--- a/partner_contact_lang/readme/DESCRIPTION.rst
+++ b/partner_contact_lang/readme/DESCRIPTION.rst
@@ -5,9 +5,9 @@ This module fills this gap, and also provides other facilities for the
contact language management:
#. Put the language of the parent company when the contact doesn't have a
-language and this parent company is assigned.
+ language and this parent company is assigned.
#. When the company changes the language, it fills with the same language all
-the contacts that don't have any.
+ the contacts that don't have any.
#. Show the language in the inner narrowed Contact form and
-set the new conctact with a different language if needed.
+ set the new conctact with a different language if needed.
#. Search and also group contacts by their language.
diff --git a/partner_contact_lang/static/description/index.html b/partner_contact_lang/static/description/index.html
index 0697b2610..3b69ab884 100644
--- a/partner_contact_lang/static/description/index.html
+++ b/partner_contact_lang/static/description/index.html
@@ -372,13 +372,15 @@ ul.auto-toc {
form, but it doesn’t allow to change it once created.
This module fills this gap, and also provides other facilities for the
contact language management:
-#. Put the language of the parent company when the contact doesn’t have a
-language and this parent company is assigned.
-#. When the company changes the language, it fills with the same language all
-the contacts that don’t have any.
-#. Show the language in the inner narrowed Contact form and
-set the new conctact with a different language if needed.
-#. Search and also group contacts by their language.
+
+- Put the language of the parent company when the contact doesn’t have a
+language and this parent company is assigned.
+- When the company changes the language, it fills with the same language all
+the contacts that don’t have any.
+- Show the language in the inner narrowed Contact form and
+set the new conctact with a different language if needed.
+- Search and also group contacts by their language.
+
Table of contents