跳至內容
選單
此問題已被標幟
2665 瀏覽次數

Hi all !

I want when I delete a object in class danh.sach.nv then object in class 'huy.hd' has fields which relate methor  many2one , will delete( all fields)

I wrote it above: But it did not work. Can anything help me?

 

 my code .py

class danh_sach_huy_hd(osv, Model):

 def unlink(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        """Allows to delete sales order lines in draft,cancel states"""
        for rec in self.browse(cr, uid, ids, context=context):
            
            if rec.ma_nv != '':
                raise osv.except_osv(_('Invalid Action!'),('Cannot delete a sales order line which is in state \'%s\'.') %(rec.state,))
        return super(danh_sach_huy_hd, self).unlink(cr, uid, ids, context=context)

 

 _columns = {
                
                'ma_nv':fields.many2one('danh.sach.nv', 'Mã NV'),
                'ten_nv':fields.related('ma_nv', 'ten_nv', type ='char', string = 'Tên nhân viên', size = 30),
                'ngay_sinh':fields.related('ma_nv', 'ngay_sinh', type ='char', string = 'Ngày sinh', size = 30),
                'ten_bp':fields.many2one('bo.phan', 'Bộ phận'),
                
                'ten_cd':fields.many2one( 'chuc.danh','Chức danh'),
               
                'ly_do_huy': fields.char('Lý do hủy hợp đồng', size = 100),
                'ngay_huy':fields.date('Ngày hủy'),
                
                }

 Can you help me?

頭像
捨棄