Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

7.0 orm.py raises exeption on write -> split_for_in_conditions has changed !

By
Joeri Belis
on 12/23/15, 2:07 PM 378 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)


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

Axel Mendoza
on 12/23/15, 3:25 PM
0
Joeri Belis
On 12/24/15, 2:55 AM

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?

Joeri Belis
on 12/24/15, 5:12 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/23/15, 2:07 PM
Seen: 378 times
Last updated: 12/24/15, 5:05 AM