Skip to Content
Menu
This question has been flagged
2 Replies
2980 Views

I installed latest 7 release from github. But were i had no problem with an older codebase of 7, i now ran into an exception raised in orm.py.

When i do a write in my custom module, orm.pay raises

  File "/home/openerp/openerp/odoo/openerp/addons/base/res/res_partner.py", line 536, in write
    result = super(res_partner,self).write(cr, uid, ids, vals, context=context)
  File "/home/openerp/openerp/odoo/openerp/addons/mail/mail_thread.py", line 297, in write
    result = super(mail_thread, self).write(cr, uid, ids, values, context=context)
  File "/home/openerp/openerp/odoo/openerp/osv/orm.py", line 4276, in write
    _('One of the records you are trying to modify has already been deleted (Document type: %s).') % self._description)


It all comes down to this piece of code in the orm.py. The 

cr.rowcount != len(sub_ids)

What could be a reason why the update would give a different rowcount vs the ids i need to update

 if len(upd0):
        self.check_access_rule(cr, user, ids, 'write', context=context)
        for sub_ids in cr.split_for_in_conditions(ids):
            cr.execute('update ' + self._table + ' set ' + ','.join(upd0) + ' ' \
                       'where id IN %s', upd1 + [sub_ids])
            if cr.rowcount != len(sub_ids):
                raise except_orm(_('AccessError'),
                                 _('One of the records you are trying to modify has already been deleted (Document type: %s).') % self._description)


Avatar
Discard

post more about your scenario, like something of how to reproduce your bug

Author Best Answer

Debugging some more i found that my ids have doubles in the list of ids

That would explain why the result from cr.rowcount = 997 and i have 1000 ids. the 3 doubles.

This is because split_for_in_conditions in sql_db.py changed between versions

from

    def split_for_in_conditions(self, ids):
"""Split a list of identifiers into one or more smaller tuples
safe for IN conditions, after uniquifying them."""
return tools.misc.split_every(self.IN_MAX, set(ids))

to:

    def split_for_in_conditions(self, ids):
"""Split a list of identifiers into one or more smaller tuples
safe for IN conditions, after uniquifying them."""
return tools.misc.split_every(self.IN_MAX, ids)

They removed the set() !

But any idea when and why this feature got changed!

And do i need to change my code to handle doubles in a list of ids i want to update?

or is this a bug that odoo is going to fix lowlevel?

Avatar
Discard
Related Posts Replies Views Activity
2
Feb 24
27129
3
Jun 23
50712
0
Jul 22
3035
0
Sep 19
98
0
Oct 17
2604