Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
10623 มุมมอง

Hello,

There is any examples or function that would delete all the values based on id list? I tryed to use the unlink i get the ID list that i want to delete but when i apply this function to my button nothing happens.

unlink function

      def unlink(self, cr, uid, ids, context=None):
        period_obj2 = self.pool.get('pp.feature')
         for fy in period_obj2.browse(cr, uid, ids, context=context):     
                featurename = fy.id
                other_table2 = period_obj2.search(cr, uid, [('plan','=',featurename)])

Button function

    def create_period5(self, cr, uid, ids, context=None):
        return self.unlink(cr, uid, ids, context)

 

Any examples and any help would be appreciated

Thank you.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

As I see, your unlink function is not deleting the records. If you decide to override any of the OSV methods, you need to make sure that you call the "super" method prior returning. Here is example:

    def unlink(self, cr, uid, ids, context=None):
        """Remove Ticket Line Record for Account Invoice Line"""
        ticket_line_obj = self.pool.get('ticket.line')
        for id in ids:
            tl_ids = ticket_line_obj.search(cr, uid, [('invoice_line_id', '=', id)], context=context)
            ticket_line_obj.unlink(cr, uid, tl_ids, context=context)                    
        return super(account_invoice_line, self).unlink(cr, uid, ids, context=context)

As you can see, after I have deleted the related objects, I am calling the super.unlink prior returning from the call. This ensures that OSV will delete the record from the database.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Nvm guys solved it, If anyone needs a example comment.

อวตาร
ละทิ้ง

can you post your example code? thanks

Related Posts ตอบกลับ มุมมอง กิจกรรม
Confirm on delete one2many line แก้ไขแล้ว
5
ก.ค. 20
10568
1
ก.ค. 19
2713
1
ส.ค. 24
6327
2
ก.ย. 21
3778
0
พ.ค. 21
4648