This question has been flagged
2 Replies
2994 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 

Avatar
Discard
Best Answer

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!

Avatar
Discard
Best Answer

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.

Avatar
Discard