تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
32633 أدوات العرض

Hi, I want to delete the records in the one2many fields when the original record that had them is deleted. I tried adding ondelete="cascade" to the one2many declaration but the records in the one2many table still remains when i delete the record holding it. How do i achieve this?

الصورة الرمزية
إهمال
أفضل إجابة

Hi,
You should put ondelete="cascade" in the field relation id like here:

class sale_order(osv.osv):
    _name = 'sale.order'
    _columns = {
        'name': fields.char('Order Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
        'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
        ....
sale_order()


class sale_order_line(osv.osv):
     _name = 'sale.order.line'
     _columns = {
        'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}),
        .
        .
        .
sale_order_line()
الصورة الرمزية
إهمال
الكاتب

Thanks, i was doing it the other way round. Now it solved the problem

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مارس 15
3225
2
مايو 24
9127
5
يوليو 20
10665
5
يناير 24
17045
0
سبتمبر 15
3827