fill primary account on selecting from account
This commit is contained in:
@@ -41,5 +41,25 @@ class Account extends \Espo\Core\ORM\Repositories\RDB
|
||||
$this->relate($entity, 'targetLists', $entity->get('targetListId'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function afterRelateContacts(Entity $entity, $foreign, $data)
|
||||
{
|
||||
if (!($foreign instanceof Entity)) return;
|
||||
|
||||
if (!$foreign->get('accountId')) {
|
||||
$foreign->set('accountId', $entity->id);
|
||||
$this->getEntityManager()->saveEntity($foreign);
|
||||
}
|
||||
}
|
||||
|
||||
protected function afterUnrelateContacts(Entity $entity, $foreign, $data)
|
||||
{
|
||||
if (!($foreign instanceof Entity)) return;
|
||||
|
||||
if ($foreign->get('accountId') && $foreign->get('accountId') === $entity->id) {
|
||||
$foreign->set('accountId', null);
|
||||
$this->getEntityManager()->saveEntity($foreign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user