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

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

By
Simon Lee
on 11/8/16, 3:26 AM 104 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:

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


0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

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

deep
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

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: 11/8/16, 3:26 AM
Seen: 104 times
Last updated: 11/10/16, 10:52 AM