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

Remove all records in class b reference to class a

By
Trai Doan
on 11/22/14, 9:14 AM 603 views

I have 2 classes

    class material(osv.osv):
            _name = "tt_material" 
            _columns = {
                'name': fields.char('Code',size=100,required=True), 
                'ten': fields.char('Name',size=100),
                'ds':fields.many2one('tt_bill','List'),
        }
    material()
    
    class bill(osv.osv):
            _name = "tt_bill" 
            _columns = {
                'name': fields.char('Code',size=20,required=True),
                'ngay':fields.date('Date'),
                'danhsach': fields.one2many('tt_material','ds','Material List'),
                 }
    bill()

When i remove a record in class bill , i want to remove all record depend on its in class material .How can i do that ? Please help me .Thanks 

1
Kelly Stuart
On 11/22/14, 9:38 PM

Hello Trai,

You can put ondelete="cascade" in the definition of 'ds' field of calss 'material'.

'ds':fields.many2one('tt_bill','List',ondelete='cascade'),

I hope this helps!

1
Mariusz Mizgier
On 11/22/14, 11:09 AM

Take a look at https://www.odoo.com/forum/help-1/question/delete-one2may-records-when-parent-record-is-deleted-30898 - that should solve your problems.

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/22/14, 9:14 AM
Seen: 603 times
Last updated: 3/16/15, 8:10 AM