changeset d47d7123b3a0 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=d47d7123b3a0
description:
        Do not update db_id when deleting XML record without noupdate

        If the record has been removed from the XML file, the db_id field will 
be
        required. So we must not update it and let convert delete the data in
        post_import.

        issue8051
        review70521002
diffstat:

 trytond/model/modelstorage.py      |   1 +
 trytond/tests/test_modelstorage.py |  20 +++++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)

diffs (48 lines):

diff -r e05af58237dd -r d47d7123b3a0 trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py     Wed Jan 30 10:07:38 2019 +0100
+++ b/trytond/model/modelstorage.py     Sun Feb 03 20:33:01 2019 +0100
@@ -277,6 +277,7 @@
                     data += ModelData.search([
                             ('model', '=', cls.__name__),
                             ('db_id', 'in', ids),
+                            ('noupdate', '=', True),
                             ])
                 ModelData.write(data, {'db_id': None})
 
diff -r e05af58237dd -r d47d7123b3a0 trytond/tests/test_modelstorage.py
--- a/trytond/tests/test_modelstorage.py        Wed Jan 30 10:07:38 2019 +0100
+++ b/trytond/tests/test_modelstorage.py        Sun Feb 03 20:33:01 2019 +0100
@@ -334,7 +334,7 @@
         self.assertTrue(result)
 
     @with_transaction()
-    def test_delete_clear_db_id_model_data(self):
+    def test_delete_clear_db_id_model_data_noupdate(self):
         "Test delete record clear DB id from model data"
         pool = Pool()
         Model = pool.get('test.modelstorage')
@@ -353,6 +353,24 @@
 
         self.assertIsNone(data.db_id)
 
+    @with_transaction(user=0)
+    def test_delete_model_data_without_noupdate(self):
+        "Test delete record from model data without noupdate"
+        pool = Pool()
+        Model = pool.get('test.modelstorage')
+        ModelData = pool.get('ir.model.data')
+        record, = Model.create([{'name': "Foo"}])
+        data, = ModelData.create([{
+                    'fs_id': 'test',
+                    'model': 'test.modelstorage',
+                    'module': 'tests',
+                    'db_id': record.id,
+                    'values': None,
+                    'noupdate': False,
+                    }])
+
+        Model.delete([record])
+
 
 def suite():
     return unittest.TestLoader().loadTestsFromTestCase(ModelStorageTestCase)

Reply via email to