mass_mailing_partner: Fix assignation of company name

Defining a res.company on a partner should not set the company_name
on a mailing contact as the mailing contact is not linked to a
res.company.
The company_name should instead be set according to the commercial
partner of the partner being modified if it's parent_id is changed.
pull/870/head
Akim Juillerat 2022-03-22 14:49:40 +01:00
parent 4e15f26e5b
commit 5ef34dc308
1 changed files with 3 additions and 3 deletions

View File

@ -79,9 +79,9 @@ class ResPartner(models.Model):
mm_vals["email"] = vals["email"]
if vals.get("title"):
mm_vals["title_id"] = vals["title"]
if vals.get("company_id"):
company = self.env["res.company"].browse(vals.get("company_id"))
mm_vals["company_name"] = company.name
if vals.get("parent_id"):
parent = self.browse(vals.get("parent_id"))
mm_vals["company_name"] = parent.commercial_company_name
if vals.get("country_id"):
mm_vals["country_id"] = vals["country_id"]
if vals.get("category_id"):