Odoo Help


Delete from one2many

on 3/11/13, 11:09 AM 4,917 views

Hello, I am having a trouble, I am trying to delete from a one2many 'on the fly'.

The fields is visible through a tree with a delete button that I created in it but when deleting it, I am getting a server error (probably because the view is not being refreshed and the just deleted field does no exist anymore):

This is the error I am getting:

Uncaught TypeError: Cannot read property 'values' of undefined

Some code:

class m1(osv.osv)
    _columns = {
        'm2_id' : fields.many2one('m1', 'Realtion'),
    def unlink(self, cr, uid, ids, context=None):
        self.write(cr, uid, ids, {'m2_id': None})
        osv.osv.unlink(self, cr, uid, ids, context=context)
        return True

In the other class, of course, I have the one2many

class m2(osv.osv)
    _columns = {
        'm1_ids' : fields.one2many('m1', 'm2_ids', 'Many Objects'),

and in the tree view of m1

   <button name="unlink" icont="gtk-remove" type="object" help="Delete m1 object"/>

(See that the function is redefined above!)

and in the form view of m2

    <field name="m1_ids" colspan="4"/>

I think that maybe I can force the view to be refreshed or something like that, because, after getting the error, I click 'OK', refresh and the object m1 has actually been deleted (and so the relation between m1 <-> m2 of course!).

Any ideas?


Parth Gajjar

--Parth Gajjar--

| 3 3 5
Ahmadabad, India
--Parth Gajjar--
Parth Gajjar
On 3/12/13, 10:29 AM

Try this one if you useing OpenERP 7.0.

<field name="m1_ids" colspan="4" options="{'always_reload': true}"/>


<field name="m1_ids" colspan="4" options="{'reload_on_button': true}">

I hope this will work

Thanks! I will try it and come back to tell you how it went! :D

on 3/12/13, 10:45 AM

Hello, this does not work in 6.1. Any workaround known?

on 10/17/13, 7:34 AM

I have exactly the same problem, but in my case options="{}" doesn't result -- any tips???

Aksana Ivanova
on 12/5/13, 8:29 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 3/11/13, 11:09 AM
Seen: 4917 times
Last updated: 3/16/15, 8:10 AM