[IMP] base: ensure parent and child partners have the same company
Purpose of the commit is to ensure parent and child partners have the same company. When creating a new child in another company and one of them tries to log a message on other contacts an error is raised due to multi company record rules. It makes no sense to have child contacts belonging to separate companies. If parent is set on contact then the company_id should be readonly and it will automatically set the parent's company_id. Task-1934813 closes: #32405 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
committed by
Barad Mahendra
parent
112a4f309e
commit
125dbf0dfd
@@ -415,6 +415,11 @@ class Partner(models.Model):
|
||||
if not self.image and self._context.get('gravatar_image') and self.email:
|
||||
self.image = self._get_gravatar_image(self.email)
|
||||
|
||||
@api.onchange('parent_id', 'company_id')
|
||||
def _onchange_company_id(self):
|
||||
if self.parent_id:
|
||||
self.company_id = self.parent_id.company_id.id
|
||||
|
||||
@api.depends('name', 'email')
|
||||
def _compute_email_formatted(self):
|
||||
for partner in self:
|
||||
|
||||
@@ -401,7 +401,7 @@
|
||||
</group>
|
||||
<group name="misc" string="Misc">
|
||||
<field name="ref" string="Reference"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" attrs="{'readonly': [('parent_id', '!=', False)]}"/>
|
||||
<field name="industry_id" attrs="{'invisible': [('is_company', '=', False)]}" options="{'no_create': True}"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user