@@ -633,7 +633,8 @@ def test_32_delete(self) -> None:
633633 self .assertIsNotNone (contacts )
634634 self .assertGreater (len (contacts ), 0 )
635635 # Delete found data
636- for entity_id in contacts :
636+ if contacts :
637+ entity_id = contacts [0 ]
637638 try :
638639 results = self .model .delete (entity_id = entity_id )
639640 self .assertTrue (results )
@@ -650,7 +651,33 @@ def test_32_delete(self) -> None:
650651 # We catched a different error, re-raise it
651652 raise error
652653
653- def test_33_language (self ) -> None :
654+ def test_33_delete_many (self ) -> None :
655+ """
656+ Delete the newly created rows.
657+ This test may be skipped in the case there's an active PoS session
658+ as Odoo doesn't allow contacts deletion when there's some active
659+ PoS session
660+ """
661+ filters = [Filter (field = 'name' ,
662+ compare_type = CompareType .CONTAINS ,
663+ value = f'{ APP_NAME } v.{ APP_VERSION } ' )]
664+ contacts = self .model .search (filters = filters )
665+ # Check if we have results
666+ self .assertIsNotNone (contacts )
667+ # Delete found data
668+ try :
669+ results = self .model .delete (entity_id = contacts )
670+ self .assertTrue (results )
671+ except xmlrpc .client .Fault as error :
672+ if error .faultCode == 2 :
673+ # We have an active PoS session running
674+ # It's not possible to delete contacts until it's closed
675+ pass
676+ else :
677+ # We catched a different error, re-raise it
678+ raise error
679+
680+ def test_34_language (self ) -> None :
654681 """
655682 Get the current default language, change and restore it
656683 """
@@ -667,15 +694,15 @@ def test_33_language(self) -> None:
667694 results = self .model .language
668695 self .assertEqual (results , original_language )
669696
670- def test_34_get_fields (self ) -> None :
697+ def test_35_get_fields (self ) -> None :
671698 """
672699 Get the model fields
673700 """
674701 results = self .model .get_fields ()
675702 # Check if we have results
676703 self .assertIsNotNone (results )
677704
678- def test_35_get_fields_attributes (self ) -> None :
705+ def test_36_get_fields_attributes (self ) -> None :
679706 """
680707 Get the model fields
681708 """
@@ -688,7 +715,7 @@ def test_35_get_fields_attributes(self) -> None:
688715 self .assertIn ('string' , field_name )
689716 self .assertIn ('type' , field_name )
690717
691- def test_36_get_model (self ) -> None :
718+ def test_37_get_model (self ) -> None :
692719 """
693720 Get a new Model object
694721 """
0 commit comments