Odoo Help


Which method is executed when clicking on trash icon in tree view

Simon Lee
on 11/8/16, 3:26 AM 662 views

I am using odoo 9. I am working in a view with a one2many field. The one2many field tree view list, there is a trash icon on the left of each row. When I click on the  trash icon, I would like to intercept record deletion and perform some custom action.

I tried to override unlink method but it does not break into the break point set inside the unlink so I think odoo is not calling unlink.  Any idea?

The view is view_pack_operation_lot_form. Here is my method:

def unlink(self): 
    res=super(myclass, self).unlink()
    # do my stuff
   return res


Techno-Functional Associate with 7+ years of experience in Odoo (formerly known as OpenERP).

On 11/9/16, 2:10 AM

It is not clear from you question whether you are calling the Unlink method of Child or Parent object.

Anyways In case of One2many, Deleting depends on the record's storage mode, i.e

  1. deletion upon saved lines (physical records)

  2. deletion upon unsaved records (cache records)

Hence when you calling Unlink method of Child Object, this will work well w.r.t Physical Records, but not on Cache records, which are not saved to the database.

So the alternate solution would be to deal with the One2many field values which you will receive in the Write Values of Parent Object.

Sorry, originally I put the unlink method in the child class (stock.pack.operation.lot) which I realize is not correct. It should be in the parent class (stock,pack.operation). So I override the parent (stock.pack.operation) unlink method. Upon deleting the row, it still does not trigger the parent class' unlink method.

In my case, it is the cache scenario since the rows are not saved yet. I cannot wait until "write" is called when clicking on the "Save" button though since I need to perform some operation on the cached rows before saving to the db.

I would like to know which method is called when the trash can icon is clicked. Then I can try to intercept and override that, I cannot locate the codes in the source. If you have ideas, please share with me. Thanks.

Simon Lee
on 11/9/16, 3:11 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

1 follower(s)


Asked: 11/8/16, 3:26 AM
Seen: 662 times
Last updated: 11/10/16, 10:52 AM