33namespace Ang3 \Component \Odoo \ORM \Normalizer ;
44
55use Ang3 \Component \Odoo \Expression \ExpressionBuilder ;
6- use Ang3 \Component \Odoo \ORM \Internal \ReflectorAwareTrait ;
76use Ang3 \Component \Odoo \ORM \Model \Collection ;
87use ProxyManager \Proxy \GhostObjectInterface ;
98use Symfony \Component \Serializer \Exception \ExceptionInterface as SerializerException ;
109
1110class 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