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

Delete from one2many

By
Lucio
on 3/11/13, 11:09 AM 3,290 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
http://localhost:/7069/web/webclient/js:3265

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

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

(See that the function is redefined above!)

and in the form view of m2

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

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?

1

Parth Gajjar

--Parth Gajjar--
1484
| 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}"/>

or

<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

Lucio
on 3/12/13, 10:45 AM

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

eLBati
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

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

0 follower(s)

Stats

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