Skip to content

Commit ff64661

Browse files
committed
Merge branch 'master' of https://github.com/Ang3/php-odoo-orm
2 parents 1ca0d58 + 6a46627 commit ff64661

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/Normalizer/CollectionNormalizer.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
namespace Ang3\Component\Odoo\ORM\Normalizer;
44

55
use Ang3\Component\Odoo\Expression\ExpressionBuilder;
6-
use Ang3\Component\Odoo\ORM\Internal\ReflectorAwareTrait;
76
use Ang3\Component\Odoo\ORM\Model\Collection;
87
use ProxyManager\Proxy\GhostObjectInterface;
98
use Symfony\Component\Serializer\Exception\ExceptionInterface as SerializerException;
109

1110
class CollectionNormalizer extends AbstractNormalizer
1211
{
13-
use ReflectorAwareTrait;
14-
1512
/**
1613
* @var ExpressionBuilder
1714
*/
@@ -38,27 +35,26 @@ public function normalize($collection, $format = null, array $context = []): arr
3835
$recordId = $record->getId();
3936

4037
if (!$recordId) {
38+
if ($record instanceof GhostObjectInterface && !$record->isProxyInitialized()) {
39+
continue;
40+
}
41+
4142
$commands[] = $this->expressionBuilder->createRecord($this->getRecordData($record));
4243
continue;
4344
}
4445

4546
$newStoredIds[] = $recordId;
4647

47-
if (!($record instanceof GhostObjectInterface)) {
48-
if (in_array($recordId, $storedIds, true)) {
49-
$commands[] = $this->expressionBuilder->updateRecord($recordId, $this->getRecordData($record));
48+
if (in_array($recordId, $storedIds, true)) {
49+
if ($record instanceof GhostObjectInterface && !$record->isProxyInitialized()) {
5050
continue;
5151
}
5252

53-
$commands[] = $this->expressionBuilder->addRecord($recordId);
54-
continue;
55-
}
56-
57-
if (!$record->isProxyInitialized()) {
53+
$commands[] = $this->expressionBuilder->updateRecord($recordId, $this->getRecordData($record));
5854
continue;
5955
}
6056

61-
$commands[] = $this->expressionBuilder->updateRecord($recordId, $this->getRecordData($record));
57+
$commands[] = $this->expressionBuilder->addRecord($recordId);
6258
}
6359

6460
foreach ($storedIds as $storedRecordId) {

0 commit comments

Comments
 (0)