[FIX] models: MissingError when writing on recordset with duplicates
When writing on a recordset with duplicates, the ORM raises a `MissingError` because the rowcount gives a difference with the injected ids. The fix simply eliminates duplicates from ids.
This commit is contained in:
committed by
Raphael Collet
parent
a46f8bb9c5
commit
08b286111c
@@ -166,6 +166,10 @@ class TestORM(common.TransactionCase):
|
||||
['date'], ['date:month', 'date:day'], lazy=False)
|
||||
self.assertEqual(len(rg), len(all_partners))
|
||||
|
||||
def test_write_duplicate(self):
|
||||
cr, uid, p1 = self.cr, self.uid, self.p1
|
||||
self.partner.write(cr, uid, [p1, p1], {'name': 'X'})
|
||||
|
||||
|
||||
class TestInherits(common.TransactionCase):
|
||||
""" test the behavior of the orm for models that use _inherits;
|
||||
|
||||
+1
-1
@@ -3896,7 +3896,7 @@ class BaseModel(object):
|
||||
self._table, ','.join('"%s"=%s' % u[:2] for u in updates),
|
||||
)
|
||||
params = tuple(u[2] for u in updates if len(u) > 2)
|
||||
for sub_ids in cr.split_for_in_conditions(ids):
|
||||
for sub_ids in cr.split_for_in_conditions(set(ids)):
|
||||
cr.execute(query, params + (sub_ids,))
|
||||
if cr.rowcount != len(sub_ids):
|
||||
raise MissingError(_('One of the records you are trying to modify has already been deleted (Document type: %s).') % self._description)
|
||||
|
||||
Reference in New Issue
Block a user